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
@@ -12,11 +12,18 @@ 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
+
// There are 3 function calls in this file. The Number() constructor is called twice on lines 4 and 5. On line 10 console.log() is also called
15
16
16
17
// 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?
18
+
// /home/kris/Code/CYF/ITP/Module-Structuring-and-Testing-Data/Sprint-1/3-mandatory-interpret/1-percentage-change.js:5 <-- this indicates the error is on line 5
// ^^^ <-- This highlights where the error is in the line. In this case the computer stops reading the code at the highlighted part because we are missing a comma after that
17
21
18
22
// c) Identify all the lines that are variable reassignment statements
23
+
// carPrice is reassigned at line 4 and priceAfterOneYear is reassigned at line 5
19
24
20
25
// d) Identify all the lines that are variable declarations
26
+
// Line 1 (carPrice), line 2 (priceAfterOneYear), line 7 (priceDifference) and line 8 (percentageChange)
21
27
22
28
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
29
+
// The replaceAll() method replaces one or more characters of a string with something different. In this case, the method just removes the comma, because the replacement value is an empty string
0 commit comments