Skip to content

Commit e974ec1

Browse files
Correct sum function to return the sum of two numbers
Fixed the sum function to return the correct value of a + b.
1 parent 03db3d4 commit e974ec1

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

  • Sprint-2/2-mandatory-debug

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
// =============> As the function is not retuning anything, we're going to see undefined on the console.
3+
34

45
function sum(a, b) {
5-
return;
6-
a + b;
6+
return a + b;
77
}
88

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

11-
// =============> write your explanation here
12+
13+
// =============> The function uses parameters a and b. It calculates the addition of a and b. Supposedly it should return the result and then we can use the value of the function, but it is returning nothing at all as return is closed without being specified.
1214
// Finally, correct the code to fix the problem
13-
// =============> write your new code here
15+
/* =============> function sum(a, b) {
16+
return a + b;
17+
}
18+
console.log(`The sum of 10 and 32 is ${(10, 32)}`);
19+
*/

0 commit comments

Comments
 (0)