Skip to content

Commit efcb14e

Browse files
committed
Fix sum function to return the correct result and update predictions and explanations
1 parent fc492bb commit efcb14e

File tree

1 file changed

+14
-2
lines changed
  • Sprint-2/2-mandatory-debug

1 file changed

+14
-2
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
// Predict and explain first...
22
// =============> write your prediction here
33

4+
// I predict that the code will output 'undefined' because the function sum does not return any value.
5+
6+
// this function should sum two numbers and return the result
7+
48
function sum(a, b) {
5-
return;
6-
a + b;
9+
return a + b;
710
}
811

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

1114
// =============> write your explanation here
15+
16+
17+
// The function sum correctly returns the sum of the two numbers, so the template literal will output the correct result.
18+
1219
// Finally, correct the code to fix the problem
1320
// =============> write your new code here
21+
22+
function sum(a, b) {
23+
return a + b;
24+
}
25+
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`); // No change needed as the code is already correct

0 commit comments

Comments
 (0)