Skip to content

Commit 7b557c2

Browse files
authored
Fix multiply function to return result
Updated the multiply function to return the product of two numbers.
1 parent 9485482 commit 7b557c2

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

  • Sprint-3/2-mandatory-debug

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// Predict and explain first...
22

33
// =============> write your prediction here
4+
// The output will be:
5+
// 320
6+
// The result of multiplying 10 and 32 is undefined
47

58
function multiply(a, b) {
69
console.log(a * b);
@@ -9,6 +12,14 @@ function multiply(a, b) {
912
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
1013

1114
// =============> write your explanation here
15+
// multiply(10, 32) runs the function and console.log(a * b) prints 320.
16+
// However, the function does not have a return statement.
17+
// A JavaScript function without a return statement returns undefined.
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+
25+
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);

0 commit comments

Comments
 (0)