@@ -13,37 +13,10 @@ console.log(`The percentage change is ${percentageChange}`);
1313
1414// a) How many function calls are there in this file? Write down all the lines where a function call is made
1515
16- // There are five functions calls.
17- //carPrice.replaceAll(",", "")
18- //Number(carPrice.replaceAll(",", ""))
19- //priceAfterOneYear.replaceAll("," "")
20- //Number(priceAfterOneYear.replaceAll("," ""))
21- //console.log(`The percentage change is ${percentageChange}`)
22-
2316// 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?
2417
25- // When I run the code the error is "syntaxError: missing ) after argument list.
26- // The error comes from line 5
27- // The error occurs due to the missing coma between the two strings in the replaceAll() call.
28- // Add coma between the two strings "priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ""));"
29-
3018// c) Identify all the lines that are variable reassignment statements
3119
32- // there are to lines that state variable reassignment
33- // carPrice = Number(carPrice.replaceAll(",", ""));
34- // priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ""));
35-
3620// d) Identify all the lines that are variable declarations
3721
38- // There are fore variable declarations (line 1, line 2, line 7, line 8)
39- // let carPrice = "10,000";
40- // let priceAfterOneYear = "8,543";
41- // const priceDifference = carPrice - priceAfterOneYear;
42- // const percentageChange = (priceDifference / carPrice) * 100;
43-
44-
4522// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
46-
47- // carprice at line 1 is a string in order to calculate for the next line of codes you have to change the string ti number.
48- // carPrice.replaceAll(",","")). delete the coma in between the number (e.g from "10,000" to "10000")
49- // number() change the string to number ("10000" to 10000)
0 commit comments