11let carPrice = "10,000" ;
22let priceAfterOneYear = "8,543" ;
3-
3+ //console.log(typeof carPrice);
44carPrice = Number ( carPrice . replaceAll ( "," , "" ) ) ;
55priceAfterOneYear = Number ( priceAfterOneYear . replaceAll ( "," , "" ) ) ;
66
@@ -11,16 +11,19 @@ console.log(`The percentage change is ${percentageChange}`);
1111
1212// Read the code and then answer the questions below
1313
14-
1514// a) How many function calls are there in this file? Write down all the lines where a function call is made
1615//5 FUNCTION calls. Line 4, 5, 10.
1716// 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?
18- //The error is coming from line 5, column 61. Thhere is nothing seprating the two indexes. A comma can be used to seprate them.
17+ //the error is SyntaxError: missing ) after argument list
18+ //The error is coming from line 5, column 61. There is nothing seprating the two indexes. A comma can should used to seprate them.
1919// c) Identify all the lines that are variable reassignment statements
2020//Two lines 4 and 5
2121// d) Identify all the lines that are variable declarations
2222//four lines 1,2,7,8
2323// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
24- //The replace.all method is used to include the car price and the price after one year of depreciation.
25- //The purpose of the expression is to take the price string and search for every comma and replace it
26- // we are saying replace this "," , with this "" and because of the empty string it means without a comma.
24+ //the expression Number(carPrice.replaceAll(",","")) change the string value to anumber that can be calculated and subtracted
25+ //line 7 needs it so the calculation could work, a string can't be subtractedn from a number so it has to be changed to a number
26+
27+ //console.log(typeof carPrice);
28+
29+ //done
0 commit comments