Skip to content

Commit bcb1815

Browse files
committed
answered 2-mandatory-debugs 1.js
1 parent 6ebd7bb commit bcb1815

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

  • Sprint-3/2-mandatory-debug

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

Lines changed: 11 additions & 4 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 result of the function supposed to print 'The sum of 10 and 32 is 42' local scope should be return to sum.
34

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

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

1112
// =============> write your explanation here
13+
// the answer is undefined because of local scope code did not return to global (sum). semicolon of return need to be removed.
1214
// Finally, correct the code to fix the problem
1315
// =============> write your new code here
16+
function sum(a, b) {
17+
return a + b;
18+
}
19+
20+
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);

0 commit comments

Comments
 (0)