Skip to content

Commit a858eb9

Browse files
committed
fixed 2-mandatory-debug
1 parent 9bca312 commit a858eb9

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

Sprint-2/2-mandatory-debug/0.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Predict and explain first...
22

33
// =============> write your prediction here
4-
// the function will not return anything.
4+
5+
// the function will not return anything, as there is no return.
6+
57
function multiply(a, b) {
68
console.log(a * b);
79
}
@@ -10,7 +12,7 @@ console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
1012

1113
// =============> write your explanation here
1214

13-
// declared a variable called result and stored a*b.
15+
// declared a variable called result and stored a*b, then return result in the function.
1416

1517
// Finally, correct the code to fix the problem
1618
// =============> write your new code here

Sprint-2/2-mandatory-debug/1.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@
22
// =============> write your prediction here
33
// This appears correct. The function has been defined and called sum, a is 10 and b is 32 so we should get 42.
44
function sum(a, b) {
5-
return;
6-
a + b;
5+
return;
6+
a + b
77
}
88

99
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
1010

1111
// =============> write your explanation here
12-
// The sum of 10 and 32 is undefined. On line five the function has been exited because of the ; this because the function doesn't return anything.
12+
13+
// The sum of 10 and 32 is undefined. On line five the function has been exited early because of the return;
14+
// a + b need to be on the same line as the return otherwise you'd get "unreachable code detected" error.
15+
1316
// Finally, correct the code to fix the problem
17+
1418
// =============> write your new code here
1519

1620
function sum(a, b) {
1721
return a + b;
18-
}
19-
20-
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
22+
}

0 commit comments

Comments
 (0)