Skip to content

Commit 484f884

Browse files
author
Pretty Taruvinga
committed
added answers to exercise 1
1 parent 8b28453 commit 484f884

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ console.log(`The percentage change is ${percentageChange}`);
3333

3434
// Line 1: let carPrice = "10,000";
3535
// Line 2: let priceAfterOneYear = "8,543";
36+
// Line 7: const priceDifference = carPrice - priceAfterOneYear;
37+
// Line 8: const percentageChange = (priceDifference / carPrice) * 100;
3638

3739
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
3840
// The expression `carPrice.replaceAll(",", "")` removes all commas from the string `carPrice`, converting it to a number that can be used in mathematical operations. This is necessary because the original value is a string with commas (e.g., "10,000"), which cannot be directly used in arithmetic calculations. The `Number()` function then converts the resulting string (e.g., "10000") into a numeric value.

0 commit comments

Comments
 (0)