Skip to content

Commit 4324216

Browse files
committed
updated percentage file
1 parent e88bd15 commit 4324216

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

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

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

44
carPrice = Number(carPrice.replaceAll(",", ""));
5-
priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ""));
5+
priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ","));
66

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

2222
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
23+
24+
25+
//Responses
26+
//a) function calls are as below:
27+
//carPrice = Number(carPrice.replaceAll(",", ""));
28+
//priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ","));
29+
//b) error = SyntaxError: missing ) after argument list
30+
// (",", ",")); - added , between quoted values
31+
//c) Variable reassignment:
32+
//carPrice = Number(carPrice.replaceAll(",", ""));
33+
//priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ","));
34+
35+
// d) Identify all the lines that are variable declarations
36+
//let carPrice = "10,000";
37+
//let priceAfterOneYear = "8,543";
38+
//const priceDifference = carPrice - priceAfterOneYear;
39+
//const percentageChange = (priceDifference / carPrice) * 100;
40+
// e) cleans the amount format by removing characters such as , and leaving only number

0 commit comments

Comments
 (0)