Skip to content

Commit e3fabaf

Browse files
committed
identified the error and fixed the syntax error on line 5
1 parent a16ba75 commit e3fabaf

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

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

Lines changed: 3 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;
@@ -12,8 +12,9 @@ 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-
//There are 5 function calls in this File. Line 4(Number and carPrice.replaceAll()), line 5(Number and priceAfterOneYear.replaceAll()) and line 10 (console.log)
15+
//There are 5 function calls in this File. Line 4(Number and carPrice.replaceAll()), line 5(Number and priceAfterOneYear.replaceAll()) and 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+
// The error message in the terminal tells me there is a syntax error on line 5. There is a comma missing separating the two arguments. I can fix the problem by adding a comma. The console now prints "The percentage change is 14.57".
1718

1819
// c) Identify all the lines that are variable reassignment statements
1920

0 commit comments

Comments
 (0)