Skip to content

Commit a2df7b1

Browse files
committed
updated c, d and e
1 parent efd42ad commit a2df7b1

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ console.log(`The percentage change is ${percentageChange}`);
2222
// The error is coming from line 5. There is a separator missing from the function call. Insert a comma to fix the problem.
2323

2424
// c) Identify all the lines that are variable reassignment statements
25-
// carPrice = Number(carPrice.replaceAll(",", ""));
26-
// priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ""));
25+
// Line 4 carPrice = Number(carPrice.replaceAll(",", ""));
26+
// Line 5 priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ""));
2727

2828
// d) Identify all the lines that are variable declarations
29-
// let carPrice = "10,000";
30-
// let priceAfterOneYear = "8,543";
31-
// const priceDifference = carPrice - priceAfterOneYear;
32-
// const percentageChange = (priceDifference / carPrice) * 100;
29+
// Line 1 let carPrice = "10,000";
30+
// Line 2 let priceAfterOneYear = "8,543";
31+
// Line 7 const priceDifference = carPrice - priceAfterOneYear;
32+
// Line 8 const percentageChange = (priceDifference / carPrice) * 100;
3333

3434
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
35+
// carPrice.replaceAll(",", "") removes every comma from the string, turning "10,000" into "10000".
36+
// Number(...) then converts that string into the number 10000.
37+
// The purpose is to turn a formatted price string into a real number so it can be used in calculations.
38+
// Without the commas removed, Number("10,000") would return NaN.

0 commit comments

Comments
 (0)