Skip to content

Commit 6bc6fa9

Browse files
committed
update: Predict and explain the output, Fix sum function to correctly return the sum of two numbers and explain code for clarity in Sprint-2/2-mandatory-debug/1.js
1 parent 58aa840 commit 6bc6fa9

File tree

1 file changed

+12
-5
lines changed
  • Sprint-2/2-mandatory-debug

1 file changed

+12
-5
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
// Predict and explain first...
22
// =============> write your prediction here
3+
// The sum of 10 and 32 is undefined
34

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

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

1112
// =============> write your explanation here
13+
// The function called `sum` is defined to take two parameters `a` and `b`, but it does not return the result of adding them together.
14+
// Instead, it has a `return` statement which exits the function without returning any value.
1215
// Finally, correct the code to fix the problem
1316
// =============> write your new code here
17+
function sum(a, b) {
18+
return a + b;
19+
}
20+
console.log(sum(10, 32));

0 commit comments

Comments
 (0)