Skip to content

Commit cd25015

Browse files
1 percentage change exercise solution
1 parent fd66c25 commit cd25015

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
let carPrice = "10,000";
2-
let priceAfterOneYear = "8,543";
1+
let carPrice = "10,000"; // variable declaration
2+
let priceAfterOneYear = "8,543"; // variable declaration
33

4-
carPrice = Number(carPrice.replaceAll(",", ""));
5-
priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ""));
4+
carPrice = Number(carPrice.replaceAll(",", "")); // variable reassignment statement and function call (.replaceall is replacing the comma for a empty space and the number() is converting the string into a number value)
5+
priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); // variable reassignment statement and function call
66

7-
const priceDifference = carPrice - priceAfterOneYear;
8-
const percentageChange = (priceDifference / carPrice) * 100;
7+
const priceDifference = carPrice - priceAfterOneYear; // variable declaration
8+
const percentageChange = (priceDifference / carPrice) * 100; // variable declaration
99

1010
console.log(`The percentage change is ${percentageChange}`);
1111

0 commit comments

Comments
 (0)