Skip to content

Commit ed78bdd

Browse files
committed
Replace console.log with return
1 parent 9af074c commit ed78bdd

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

  • Sprint-2/2-mandatory-debug

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

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

3-
// =============> write your prediction here
3+
// The result of multiplying 10 and 32 is expected to be undefined because the multiply() function does not return the result.
4+
// It only prints it using console.log().
5+
46

57
function multiply(a, b) {
68
console.log(a * b);
79
}
810

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

11-
// =============> write your explanation here
13+
// After running the code, the result of multiplying 10 and 32 is undefined indeed.
14+
// The problem occurs because the function has no return statement to send a value back to where the function was called.
1215

1316
// Finally, correct the code to fix the problem
14-
// =============> write your new code here
17+
// function multiply(a, b) {
18+
// return a * b;
19+
// }
20+
21+
// console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);

0 commit comments

Comments
 (0)