Skip to content

Commit a79905f

Browse files
Fix sum function to correctly return the sum of two numbers
1 parent b3a0d25 commit a79905f

File tree

1 file changed

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

1 file changed

+11
-7
lines changed

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
// =============> write your prediction here: The function will not return the sum of a and b because there is a syntax error.
33

4-
function sum(a, b) {
5-
return;
6-
a + b;
7-
}
4+
// function sum(a, b) {
5+
// return;
6+
// a + b;
7+
// }
88

9-
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
9+
//console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
1010

11-
// =============> write your explanation here
11+
// =============> write your explanation here : return should be on the same line as a + b.
1212
// Finally, correct the code to fix the problem
1313
// =============> write your new code here
14+
function sum (a,b){
15+
return a+b;
16+
}
17+
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);

0 commit comments

Comments
 (0)