Skip to content

Commit ad1ca7f

Browse files
authored
Fixed the function to return the sum of 2 parameters properly
Corrected the sum function to return the sum of two numbers instead of undefined.
1 parent a10df18 commit ad1ca7f

File tree

1 file changed

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

1 file changed

+16
-7
lines changed

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
// =============> write your prediction here: js is a sequential language, as in reads code line by line, so i predict nothing will happen after 'return' is processed and
3+
//some sort of an error message will appear.
4+
5+
//function sum(a, b) {
6+
// return;
7+
// a + b;
8+
//}
9+
10+
//console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
11+
12+
// =============> write your explanation here: 'undefined' error appeared. Fixed the code by adding the addition on the same line as return.
13+
14+
15+
// Finally, correct the code to fix the problem
16+
// =============> write your new code here:
317

418
function sum(a, b) {
5-
return;
6-
a + b;
19+
return a + b;
720
}
821

922
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
10-
11-
// =============> write your explanation here
12-
// Finally, correct the code to fix the problem
13-
// =============> write your new code here

0 commit comments

Comments
 (0)