Skip to content

Commit 5b6ddbd

Browse files
committed
corrected the error in line 5
1 parent a5ef875 commit 5b6ddbd

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

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

Lines changed: 8 additions & 1 deletion
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,11 +12,18 @@ 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+
// line 4, number() and replaceAll()
16+
// line 5, number() and replaceAll()
17+
// line 10, console.log()
1518

1619
// 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?
20+
// The was a missing comma in line 5.
1721

1822
// c) Identify all the lines that are variable reassignment statements
23+
// line 4 and line 5
1924

2025
// d) Identify all the lines that are variable declarations
26+
// line 1,line 2, line 7, line 8
2127

2228
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
29+
// The expression changes the string to a number and removes the comma. This makes it possible for Javascript to perform subtraction since it is no longer a string

0 commit comments

Comments
 (0)