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
// Line 1 is a variable declaration, creating the count variable with an initial value of 0
6
-
// Describe what line 3 is doing, in particular focus on what = is doing
1
+
letcount=0;
2
+
3
+
count=count+1;
4
+
//Line 1 is variable declaration, creating the count variable with an initial value of 0
5
+
//Line 3 takes the current value of count (0), adds 1 to it (0 + 1 = 1), and uses the assignment operator (=) to reassign and store this new value (1) back into the count variable.
6
+
// Line 1 is a variable declaration, creating the count variable with an initial value of 0
7
+
// Describe what line 3 is doing, in particular focus on what = is doing
console.log(`The percentage change is ${percentageChange}`);
11
+
12
+
// Read the code and then answer the questions below
13
+
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
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?
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
+
23
+
// c) Identify all the lines that are variable reassignment statements
24
+
//answer: lines 4 and 5
25
+
26
+
// d) Identify all the lines that are variable declarations
27
+
//answer: line 1, 2, 7 and 8
28
+
29
+
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
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