Skip to content

Commit 96ebf89

Browse files
committed
In 2-mandatory-debug/0.js, updated return in the function
1 parent 24f2d3c commit 96ebf89

File tree

1 file changed

+12
-2
lines changed
  • Sprint-2/2-mandatory-debug

1 file changed

+12
-2
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
// Predict and explain first...
22

33
// =============> write your prediction here
4-
4+
// It seems the function multiply did not return any value.
5+
// Therefore, it is like a console.log returning undefined, while it is inside another console.log.
6+
// So the output should be "The result of multiplying 10 and 32 is undefined".
7+
/*
58
function multiply(a, b) {
69
console.log(a * b);
710
}
811
912
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
10-
13+
*/
1114
// =============> write your explanation here
15+
// After running the code, I got a separate output of 320 and "The result of multiplying 10 and 32 is undefined".
16+
// This is because the function multiply does not return any value, so it returns undefined by default.
17+
// The console.log inside the function multiply prints 320 when the function is called.
1218

1319
// Finally, correct the code to fix the problem
1420
// =============> write your new code here
21+
function multiply(a, b) {
22+
return a * b;
23+
}
24+
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); // should return "The result of multiplying 10 and 32 is 320"

0 commit comments

Comments
 (0)