Skip to content

Commit de2b780

Browse files
committed
debug 1.js in Sprint 2 > 2-mandatory-debug
1 parent 9cad53a commit de2b780

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

  • Sprint-2/2-mandatory-debug

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
// =============> return is not followed by anything (directly), and a+b is after the ";" after return. in a function nothing gets executed after return
33

44
function sum(a, b) {
55
return;
@@ -8,6 +8,11 @@ function sum(a, b) {
88

99
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
1010

11-
// =============> write your explanation here
11+
// =============> return value is undefined, so in the console log sentence the result (return value) is substituted with "undefined" instead of the actual sum
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+
18+
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);

0 commit comments

Comments
 (0)