Skip to content

Commit 588db92

Browse files
committed
Fix multiply function to return the product instead of logging it
1 parent 701d553 commit 588db92

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

  • Sprint-3/2-mandatory-debug

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

Lines changed: 12 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+
// I predict that the output of the console.log statement will be "The result of multiplying
5+
// 10 and 32 is undefined" because the multiply function does not return a value, it only
6+
// logs the result to the console.
47

58
function multiply(a, b) {
69
console.log(a * b);
@@ -9,6 +12,15 @@ 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+
// The multiply function takes two parameters, a and b, and logs the product of a and b to
16+
// the console. However, it does not return any value. When the function is called inside
17+
// the template literal, it returns undefined, which is why the output of the console.log
18+
// statement includes "undefined".
1219

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

0 commit comments

Comments
 (0)