File tree Expand file tree Collapse file tree
Sprint-2/3-mandatory-interpret Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ let carPrice = "10,000";
22let priceAfterOneYear = "8,543" ;
33
44carPrice = Number ( carPrice . replaceAll ( "," , "" ) ) ;
5- priceAfterOneYear = Number ( priceAfterOneYear . replaceAll ( "," "" ) ) ;
5+ priceAfterOneYear = Number ( priceAfterOneYear . replaceAll ( "," , "" ) ) ;
66
77const priceDifference = carPrice - priceAfterOneYear ;
88const percentageChange = ( priceDifference / carPrice ) * 100 ;
@@ -20,3 +20,16 @@ console.log(`The percentage change is ${percentageChange}`);
2020// d) Identify all the lines that are variable declarations
2121
2222// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
23+
24+ // Answers
25+
26+ // a) There are no function or function calls in this code.
27+
28+ // b) The error was online 5 inside replaceAll method parentheses a comma is missing between the double quotes.
29+
30+ // c) Line 4 carPrice. Line 5 priceAfterOneYear.
31+
32+ // d) Line 1, 2, 7 and 8.
33+
34+ // e) The method replaceALL is removing the comma. Then the Number method is converting the string into numbers.
35+ // The purpose is to use number operations and calculate the percentage change.
You can’t perform that action at this time.
0 commit comments