Skip to content

Commit 74687a6

Browse files
author
Payman IB
committed
1-percentage-change completed => questions are answered.
1 parent 8ddf08f commit 74687a6

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,33 @@ console.log(`The percentage change is ${percentageChange}`);
1111

1212
// Read the code and then answer the questions below
1313

14-
// a) How many function calls are there in this file? Write down all the lines where a function call is made
14+
// a) How many function calls are there in this file? Write down all the lines where a function call is made
15+
16+
// lines 4,5,7,8
17+
// the following 4 lines are functions as they are manipulating the data.
18+
//carPrice = Number(carPrice.replaceAll(",", ""));
19+
//priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ,""));
20+
//const priceDifference = carPrice - priceAfterOneYear;
21+
//const percentageChange = (priceDifference / carPrice) * 100;
1522

1623
// b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem?
1724

25+
// line 5
26+
// priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); the error is a missing "," in ...replaceAll("," , "")). with out a "," the " "" are not separated and computer read them together.
27+
1828
// c) Identify all the lines that are variable reassignment statements
1929

30+
// lines 4,5
31+
//carPrice = Number(carPrice.replaceAll(",", ""));
32+
//priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ""));
33+
34+
//carPrice = Number(carPrice.replaceAll(",", ""));
35+
//priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ""));
36+
37+
2038
// d) Identify all the lines that are variable declarations
2139

40+
// lines 1,2,7,8
41+
2242
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
43+
// it replace the "," with "" which means omitting the "," so we have whole number that computer can work with it.

0 commit comments

Comments
 (0)