Skip to content

Commit bba3df3

Browse files
committed
answered questions
1 parent 9f4f143 commit bba3df3

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎Sprint-2/3-mandatory-interpret/1-percentage-change.js‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ console.log(`The percentage change is ${percentageChange}`);
1212
// Read the code and then answer the questions below
1313

1414
// a) How many function calls are there in this file? Write down all the lines where a function call is made
15-
15+
There are 5 function calls, two function calls on line 4 = Number(...) and replaceAll(...) two more on line 5 = Number(...) and replaceAll(...) and finally on line 10 = console.log(...)
1616
// b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem?
17-
17+
SyntaxError: missing a comma to separate the arguments
1818
// c) Identify all the lines that are variable reassignment statements
19-
19+
carPrice = Number(carPrice.replaceAll(",", "")); and priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ""));
2020
// d) Identify all the lines that are variable declarations
21-
21+
There are 4 variable declarations- 1) let carPrice = "10,000"; 2) let priceAfterOneYear = "8,543";
22+
3) const priceDifference = carPrice-priceAfterOneYear; 4) const percentageChange = (priceDifferenc/carPrice)* 100;
2223
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
24+
Number(carPrice.replaceAll(",", "")); is a string and the expression removes the comma from "10,000" and converts "10000" from a string into the number 10000.

0 commit comments

Comments
 (0)