Skip to content

Commit b2f87c5

Browse files
committed
In 2-mandatory-debug/1.js, updated return inline with a+b
1 parent 96ebf89 commit b2f87c5

File tree

1 file changed

+11
-1
lines changed
  • Sprint-2/2-mandatory-debug

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
// Predict and explain first...
22
// =============> write your prediction here
3+
// It looks like the function sum return nothing because a+b is written in the next line after return statement.
4+
// Therefore, the output should be "The sum of 10 and 32 is undefined".
35

6+
/*
47
function sum(a, b) {
58
return;
69
a + b;
710
}
811
912
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
10-
13+
*/
1114
// =============> write your explanation here
15+
// After running the code, I got "The sum of 10 and 32 is undefined".
16+
// The return statement ends the function execution and a+b is never evaluated.
17+
1218
// Finally, correct the code to fix the problem
1319
// =============> write your new code here
20+
function sum(a, b) {
21+
return a + b;
22+
}
23+
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); // should return "The sum of 10 and 32 is 42"

0 commit comments

Comments
 (0)