@@ -12,26 +12,11 @@ console.log(`The percentage change is ${percentageChange}`);
1212// Read the code and then answer the questions below
1313
1414// a) How many function calls are there in this file? Write down all the lines where a function call is made
15- //1. Line 5: carPrice.replaceAll(",", "")
16- //2. Line 6: priceAfterOneYear.replaceAll(",", "")
17- //3. Line 8: console.log(`The percentage change is ${percentageChange}`)
1815
1916// 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?
20- //The error is in line 5, the error is occurring because there was a comma missing here; ("," "").
2117
2218// c) Identify all the lines that are variable reassignment statements
23- //carPrice = Number(carPrice.replaceAll(",", ""));
24- //priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",",""));
2519
2620// d) Identify all the lines that are variable declarations
27- //let carPrice = "10,000";
28- //let priceAfterOneYear = "8,543";
29- //const priceDifference = carPrice - priceAfterOneYear;
30- //const percentageChange = (priceDifference / carPrice) * 100;
31-
3221
3322// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
34- //The expression is converting the string representation of the car price to a number by first removing the comma.
35-
36- //Purpose:
37- //To allow the computer identify the value of the car price as a number so that it can be used in calculations.
0 commit comments