Skip to content

Commit 7fbd07f

Browse files
authored
Fix sum function to return correct value
Corrected the sum function to return the sum of two numbers.
1 parent b594c90 commit 7fbd07f

File tree

1 file changed

+9
-3
lines changed
  • Sprint-2/2-mandatory-debug

1 file changed

+9
-3
lines changed

Sprint-2/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+
// =============> The sum of 10 and 32 is undefined
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+
// =============> the function sum returns Nul because it's straight followed by semicolon thate ends the statement
12+
// also the statement a + b is in new line
1213
// Finally, correct the code to fix the problem
13-
// =============> write your new code here
14+
// =============> my new code
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)