Skip to content

Commit e93943e

Browse files
Update comments in 1.js to clarify function behavior and fix error
1 parent 7ade54a commit e93943e

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
// =============> the return statement is placed before the actual sum,
3+
// which means that the function will return undefined before it can calculate the sum of a and b.
4+
// Therefore, the output will be "The sum of 10 and 32 is undefined".
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
13+
// =============> The program behaved as predicted
1214
// Finally, correct the code to fix the problem
1315
// =============> write your new code here
16+
17+
function sum(a, b) {
18+
add = a + b;
19+
return add;
20+
}
21+
22+
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Predict and explain first...
22

33
// Predict the output of the following code:
4-
// =============> Write your prediction here
4+
// =============>
55

66
const num = 103;
77

0 commit comments

Comments
 (0)