Skip to content

Commit af75a19

Browse files
committed
complete ex 1.js
1 parent 9650964 commit af75a19

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

  • Sprint-3/2-mandatory-debug

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
// =============> I predict the code won't work because there's a ";" after return.
33

4-
function sum(a, b) {
4+
/*function sum(a, b) {
55
return;
66
a + b;
77
}
88
9-
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
9+
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);*/
1010

11-
// =============> write your explanation here
11+
/* =============> The sum is undefined because the semicolon after return ends it too early,
12+
the function returns before adding a and b.*/
1213
// Finally, correct the code to fix the problem
1314
// =============> write your new code here
15+
function sum(a, b) {
16+
return a + b;
17+
}
18+
19+
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);

0 commit comments

Comments
 (0)