Skip to content

Commit 3c54085

Browse files
committed
Fix multiply function return
1 parent 500a0f6 commit 3c54085

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

  • Sprint-3/2-mandatory-debug

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

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

3+
// Prediction: I predict that the function will print 320,
4+
// but the final message will say undefined because the function
5+
// does not return the result.
6+
37
// =============> write your prediction here
48

59
function multiply(a, b) {
6-
console.log(a * b);
10+
return a * b;
711
}
812

913
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
1014

1115
// =============> write your explanation here
1216

17+
// Explanation: console.log() displays a value on the screen,
18+
// but return sends a value back from the function.
19+
// The original function used console.log() instead of return,
20+
// so the function returned undefined.
21+
1322
// Finally, correct the code to fix the problem
14-
// =============> write your new code here
23+
// =============> write your new code here
24+
25+
// The corrected function returns the result of multiplying a and b.

0 commit comments

Comments
 (0)