Skip to content

Commit 65cb89c

Browse files
committed
Complete debug exercise 0 - multiply return value
1 parent e7b50d9 commit 65cb89c

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

  • Sprint-3/2-mandatory-debug

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
// Predict and explain first...
2-
3-
// =============> write your prediction here
2+
// Prediction: multiply logs 320 but returns undefined, so the template
3+
// string prints: "The result of multiplying 10 and 32 is undefined"
44

55
function multiply(a, b) {
6-
console.log(a * b);
6+
return a * b;
77
}
88

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

11-
// =============> write your explanation here
12-
13-
// Finally, correct the code to fix the problem
14-
// =============> write your new code here
11+
// Explanation: console.log inside a function only prints; it does not return
12+
// a value. Without return, the function result is undefined. Using return
13+
// gives 320 so the template string shows the correct message.

0 commit comments

Comments
 (0)