Skip to content

Commit 5f4ae71

Browse files
Committing the actions for 1.js
1 parent 47bd57d commit 5f4ae71

1 file changed

Lines changed: 21 additions & 10 deletions

File tree

  • Sprint-2/2-mandatory-debug

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

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1-
// Predict and explain first...
2-
// =============> write your prediction here
1+
// Predict and explain first...
2+
// =============> write your prediction here
3+
// I predict that the function will not return undefined.
4+
// This is due to the fact that the return statement is on its own line, therefore trying to do the addition will not work as the code is not read.
35

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

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

11-
// =============> write your explanation here
12-
// Finally, correct the code to fix the problem
13-
// =============> write your new code here
13+
// =============> write your explanation here
14+
// The return statement is written on its own line, therefore JS automatically inserts a semicolon after the return.
15+
// This means that the function exits immediately and returns undefined.
16+
// The expression a + b; is not executed.
17+
18+
// Finally, correct the code to fix the problem
19+
// =============> write your new code here
20+
function sum(a, b) {
21+
return a + b;
22+
}
23+
24+
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);

0 commit comments

Comments
 (0)