@@ -2,13 +2,21 @@ 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+ //a) There are 4 function calls in this file. They are on lines 1, 2, 4, and 5.
13+ //b) The error is in line 4 and 5. The error is occurring because the replaceAll function is being called on a string,
14+ // but the string has not been converted to a number.
15+ //c) The variable reassignment statements are in lines 4 and 5
16+ //d) The variable declarations are in lines 1,2,7, and 8.
17+ //e) The expression Number(carPrice.replaceAll(",","")) is converting the string carPrice into a number
18+ // by removing the commas and then converting the resulting string into a number. from "10,000" to "10000" to 10000
19+
1220// Read the code and then answer the questions below
1321
1422// a) How many function calls are there in this file? Write down all the lines where a function call is made
0 commit comments