Skip to content

Commit d460d91

Browse files
committed
Add return value to multiply()
1 parent f98987f commit d460d91

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

  • Sprint-2/2-mandatory-debug

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

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

33
// =============> write your prediction here
4+
//I think this code will not show the correct result because the function logs the answer instead of returning it.
45

5-
function multiply(a, b) {
6+
/*function multiply(a, b) {
67
console.log(a * b);
78
}
89
9-
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
10+
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);*/
1011

1112
// =============> write your explanation here
13+
/*First, the function multiplies 10 and 32 and prints the result. However, in the second console.log
14+
the value becomes undefined because the function does not return anything, so the template string
15+
receives undefined instead of the number.*/
1216

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

0 commit comments

Comments
 (0)