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-1/1-key-exercises/1-count.js
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -4,3 +4,4 @@ count = count + 1;
4
4
5
5
// Line 1 is a variable declaration, creating the count variable with an initial value of 0
6
6
// Describe what line 3 is doing, in particular focus on what = is doing
7
+
// Line 3 reassigns the variable count by taking its current value, adding 1 to it, and storing the new value back into count. The = operator assigns the value on the right to the variable on the left.
@@ -12,11 +12,16 @@ 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 is 5 function calls, anything that has () afterwards is a function.
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
+
// I added a a comma , here --> (priceAfterOneYear.replaceAll(",", "")); as this was missing, I seen this as soon as i opened this exercise.
17
19
18
20
// c) Identify all the lines that are variable reassignment statements
21
+
// Lines 4 and 5 are reassignments, carPrice was declared with let and priceAfterOneYear was already declared with let.
19
22
20
23
// d) Identify all the lines that are variable declarations
24
+
// There is 4 declarations in total, theres where all varibales crated using let,const and var. (lines 1,2,7,8)
21
25
22
26
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
27
+
// breaking it down this part, carPrice.replaceAll(",", "") removes all commas from the string. Next step is this Number("10000"), this converts the string into a number.
0 commit comments