Skip to content

Commit 6be81b5

Browse files
committed
percentage-change.js file update
1 parent c580390 commit 6be81b5

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

Sprint-1/3-mandatory-interpret/1-percentage-change.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ let carPrice = "10,000";
22
let priceAfterOneYear = "8,543";
33

44
carPrice = Number(carPrice.replaceAll(",", ""));
5-
priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ""));
5+
// console.log(carPrice)
6+
priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ""));
67

78
const priceDifference = carPrice - priceAfterOneYear;
89
const percentageChange = (priceDifference / carPrice) * 100;
@@ -20,3 +21,17 @@ console.log(`The percentage change is ${percentageChange}`);
2021
// d) Identify all the lines that are variable declarations
2122

2223
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
24+
25+
26+
27+
// a) There are 2 function calls in this code. replaceAll() in line 4 and 5 and console.log() in line 10
28+
29+
// b) There is a SyntaxError on line 5. The replaceAll() function takes 2 arguments
30+
// and this is missing a comma between the 2 arguments
31+
32+
//c) line 4 & 5
33+
34+
// d) line 1,2 7 & 8
35+
36+
// e) It is replaces the comma "," in carPrice and removes any spaces so
37+
// everything becomes one string

0 commit comments

Comments
 (0)