Skip to content

Commit 8b9263a

Browse files
fix: correct sum function implementation and update comments for clarity
1 parent a4f1b8e commit 8b9263a

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

  • Sprint-3/2-mandatory-debug

‎Sprint-3/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+
// By using the semi-colon after the return, this is closing off the function and leaving the parameters as undefined, causing the console.log state that the parameters are undefined.
33

4+
// function sum(a, b) {
5+
// return;
6+
// a + b;
7+
// }
8+
9+
// console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
10+
11+
// by using the semi-colon after the return, and having the parameters put into a separate line, the return can't define the parameters of the function.
12+
// Finally, correct the code to fix the problem
413
function sum(a, b) {
5-
return;
6-
a + b;
14+
return a + b;
715
}
816

917
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)