Skip to content

Commit 0da267c

Browse files
committed
updating answers after reviews
1 parent ff710ae commit 0da267c

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

Sprint-1/1-key-exercises/4-random.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
1111
// Math.floor - Rounds a number DOWN to the nearest integer
1212
// Math.random - generates a random floating number > 0 and < 1
1313
// (maximum - minimum + 1) = 100 - 1 + 1 = 100
14-
// So, num represents a rounded down random integer generated between 1 and 100 + 1
15-
16-
console.log(num);
14+
// So, num represents a rounded down random integer generated between 1 and 100
15+
// Edge case: Math.floor(99.99) + 1 = 99 + 1 = 100
16+
console.log(num);

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,27 @@ console.log(`The percentage change is ${percentageChange}`);
1313

1414
// a) How many function calls are there in this file? Write down all the lines where a function call is made
1515

16-
// There are 4 function calls in this file
17-
// Line 4: carPrice.replaceAll(",", "")
18-
// Line 4: Number(carPrice.replaceAll(",", ""))
19-
// Line 5: priceAfterOneYear.replaceAll("," "")
20-
// Line 5: Number(priceAfterOneYear.replaceAll("," ""))
16+
// There are 5 function calls in this file
17+
// Line 4: carPrice.replaceAll(",", "")
18+
// Line 4: Number(carPrice.replaceAll(",", ""))
19+
// Line 5: priceAfterOneYear.replaceAll("," "")
20+
// Line 5: Number(priceAfterOneYear.replaceAll("," ""))
21+
// Line 8: console.log(`The percentage change is ${percentageChange}`)
2122

2223
// 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?
2324

24-
// The error is coming from line 5
25-
// The error is due to a missing comma
26-
// Add a comma between the two quotations
25+
// The error is coming from line 5
26+
// The error is due to a missing comma
27+
// Add a comma between the two quotations
2728

2829
// c) Identify all the lines that are variable reassignment statements
2930

30-
// Line 4 and Line 5
31+
// Line 4 and Line 5
3132

3233
// d) Identify all the lines that are variable declarations
3334

34-
// Line 1, Line 2, Line 7 and Line 8
35+
// Line 1, Line 2, Line 7 and Line 8
3536

3637
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
3738

38-
// The expression is replacing all the commas in the string carPrice with nothing, and then converting it to a number type
39+
// The expression is replacing all the commas in the string carPrice with nothing, and then converting it to a number type

0 commit comments

Comments
 (0)