Skip to content

Commit 9493010

Browse files
committed
Finished mandatory interpret 1
1 parent 195927c commit 9493010

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,18 @@ console.log(`The percentage change is ${percentageChange}`);
1212
// Read the code and then answer the questions below
1313

1414
// a) How many function calls are there in this file? Write down all the lines where a function call is made
15+
// There are 4 function calls on lines 4 to 5.
1516

1617
// 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+
// Error occurs on line 5 because the second argument to replaceAll is missing quotes.
19+
// Fix: Change `replaceAll("," ""))` to `replaceAll(",", ""))`
1720

1821
// c) Identify all the lines that are variable reassignment statements
22+
// Line 4: carPrice = Number(carPrice.replaceAll(",", ""));
23+
// Line 5: priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ""));
1924

2025
// d) Identify all the lines that are variable declarations
26+
// Line 1 and line 2.
2127

2228
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
29+
// The expression removes commas from the string carPrice and converts it to a number.

0 commit comments

Comments
 (0)