You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sprint-1/3-mandatory-interpret/1-percentage-change.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ console.log(`The percentage change is ${percentageChange}`);
20
20
// line 10: console.log(`The percentage change is ${percentageChange}`);
21
21
22
22
// 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?
23
-
// The error is occurring on 4 where we are trying to convert the string values of carPrice and priceAfterOneYear to numbers using the Number function. The error is occurring because the replaceAll method is being called on a string that has not been updated with the new value after the first replaceAll call. To fix this problem, we can update the carPrice and priceAfterOneYear variables with the new values after the replaceAll calls. For example:
23
+
// Error on line 5 where comma was missing in replaceAll functioncall.
24
24
25
25
// c) Identify all the lines that are variable reassignment statements
26
26
// Line 4: carPrice = Number(carPrice.replaceAll(",", ""));
0 commit comments