Skip to content

Commit adc7447

Browse files
committed
Fixed error on line 17
1 parent d2210f1 commit adc7447

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ let carPrice = "10,000";
22
let priceAfterOneYear = "8,543";
33

44
carPrice = Number(carPrice.replaceAll(",", ""));
5-
priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ""));
5+
priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ""));
66

77
const priceDifference = carPrice - priceAfterOneYear;
88
const percentageChange = (priceDifference / carPrice) * 100;
@@ -14,7 +14,7 @@ console.log(`The percentage change is ${percentageChange}`);
1414
// a) How many function calls are there in this file? Write down all the lines where a function call is made
1515
// Answer: There are 5 function calls in total. They are located on lines 4, 5, and 10.
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-
// Answer: The error comes from line 4. Since JavaScript executes from top to bottom, it crashes on line 4 because we are trying to reassign a new value to `carPrice`, which was originally declared as a `const`. To fix it, change `const` to `let` on lines 1 and 2.
17+
// Answer: The error comes from line 5. The error was that there was a comma missing in the replaceAll function.
1818
// c) Identify all the lines that are variable reassignment statements
1919
// Answer: Lines 4 and 5.
2020
// d) Identify all the lines that are variable declarations

0 commit comments

Comments
 (0)