@@ -2,7 +2,7 @@ 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 ;
@@ -12,7 +12,7 @@ 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- // there are 5 function calls
15+ // there are 5 function calls
1616//carPrice.replaceAll(",", "")
1717//Number(carPrice.replaceAll(",", ""))
1818//priceAfterOneYear.replaceAll(",", "")
@@ -25,7 +25,6 @@ console.log(`The percentage change is ${percentageChange}`);
2525// c) Identify all the lines that are variable reassignment statements
2626//priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); missing a comma between the two arguments of replaceAll()
2727
28-
2928// d) Identify all the lines that are variable declarations
3029// let carPrice = "10,000";
3130//let priceAfterOneYear = "8,543";
@@ -38,11 +37,11 @@ console.log(`The percentage change is ${percentageChange}`);
3837//So the whole expression:Number(carPrice.replaceAll(",", ""))converts "10,000"
3938//from a string containing a comma into the actual number 10000.
4039//"10,000"
41- // ↓
40+ // ↓
4241//remove ","
43- // ↓
42+ // ↓
4443// //"10000"
4544// ↓
4645// convert to Number
4746// ↓
48- // 10000
47+ // 10000
0 commit comments