You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sprint-2/3-mandatory-interpret/1-percentage-change.js
+12-9Lines changed: 12 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -12,16 +12,19 @@ console.log(`The percentage change is ${percentageChange}`);
12
12
// Read the code and then answer the questions below
13
13
14
14
// a) How many function calls are there in this file? Write down all the lines where a function call is made
15
-
//answer: we have 5 function calls across 3 lines:
16
-
//line 4
17
-
//line 5
18
-
//line 10
15
+
//answer: we have 5 function calls across 3 lines:
16
+
//line 4
17
+
//line 5
18
+
//line 10
19
+
19
20
// 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?
20
-
//answer: on line 5, there is a typo, a replaceAll("," ""));
21
-
//fix line 5 by changing it to priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ""));
21
+
//answer: on line 5, there is an error caused by a missing comma replaceAll("," ""));. Can be fixed by changing it to priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ""));
22
+
22
23
// c) Identify all the lines that are variable reassignment statements
23
-
//answer: lines 4 and 5
24
+
//answer: lines 4 and 5
25
+
24
26
// d) Identify all the lines that are variable declarations
25
-
//answer: line 1, 2, 7 and 8
27
+
//answer: line 1, 2, 7 and 8
28
+
26
29
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
27
-
//answer: .ReplaceAll(",", "") this will remove a comma from the price string and number will convert that clean string into a numeric value so mathematical calculations can be perfomed.
30
+
//answer: .ReplaceAll(",", "") this will remove every comma from the price string and number will convert that clean string into a numeric value so mathematical calculations can be performed.
0 commit comments