Skip to content

Commit da1d102

Browse files
committed
fix debug 1
1 parent 0c19af2 commit da1d102

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

  • Sprint-3/2-mandatory-debug

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
// =============> This will not work because the a + b statement should have been after return, but return has a semicolon after it which stops the function an returns nothing
33

44
function sum(a, b) {
55
return;
@@ -8,6 +8,12 @@ function sum(a, b) {
88

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

11-
// =============> write your explanation here
11+
// =============> Because return and a+b are not on the same line, the line after return is never reached, and would be considered dead code and therefore the console logs argument as undefined
12+
1213
// Finally, correct the code to fix the problem
13-
// =============> write your new code here
14+
15+
function sum(a, b) {
16+
return a + b;
17+
}
18+
19+
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);

0 commit comments

Comments
 (0)