Skip to content

Commit 8211642

Browse files
committed
edit my Answer in the comment section
1 parent 5da1022 commit 8211642

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@ 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;
99

1010
console.log(`The percentage change is ${percentageChange}`);
1111

12-
13-
14-
15-
// There are two function calls. line 4 and 5
16-
//The error is coming from the line 5, because there was no comma in the replaceAll() method .
17-
// line 4 and 5 are the variable reassignment statments.
18-
// line 1 ,2 ,7 and 8 are lines where variable declarions happened
19-
// the method .replaceAll is replacing the coma (,) in the 10,000 and throws it 10000, the number function converts it into a number.
12+
//1. There are 4 function calls in line 4 and 5
13+
// * number()and the second one is .replaceall() in line 4
14+
// * number() and the second one is .replaceall()in line 4
15+
// 2. The error is coming from the line 5, because there was no comma in the replaceAll() method .
16+
// 3. line 4 and 5 are the variable reassignment statments.
17+
// 4. line 1 ,2 ,7 and 8 are lines where variable declarions happened
18+
// 5. *The method .replaceAll() in line 4 is replacing the coma (,) with nothing("") in the "10,000" and the output is "10000",
19+
// the number function converts the string "10000" into a number.
20+
// *The method .replaceAll() in line 4 is replacing the coma(,) with nothing("") in the "8,543" and the output is "8543"
21+
// the number function coverts the string "8543" into a number which is 8543.

0 commit comments

Comments
 (0)