@@ -2,18 +2,20 @@ let carPrice = "10,000";
22let priceAfterOneYear = "8,543" ;
33
44carPrice = Number ( carPrice . replaceAll ( "," , "" ) ) ;
5- priceAfterOneYear = Number ( priceAfterOneYear . replaceAll ( "," , "" ) ) ;
5+ priceAfterOneYear = Number ( priceAfterOneYear . replaceAll ( "," , "" ) ) ;
66
77const priceDifference = carPrice - priceAfterOneYear ;
88const percentageChange = ( priceDifference / carPrice ) * 100 ;
99
1010console . 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