Skip to content

Commit 1d044cb

Browse files
committed
Fix multiply function to return result
1 parent a128bbf commit 1d044cb

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

  • Sprint-3/2-mandatory-debug

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

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

3-
// =============> write your prediction here
3+
// =============> write your prediction here:
4+
//The code will run, but the output won't be what we expect because the multiply function logs the result instead of returning it.
45

56
function multiply(a, b) {
67
console.log(a * b);
78
}
89

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

11-
// =============> write your explanation here
12-
12+
// =============> write your explanation here:console.log(a * b);
13+
//The result is 320, but the function doesn't return a value. It shows us undefined because we don't have return in the function.
14+
//320
15+
//The result of multiplying 10 and 32 is undefined
1316
// Finally, correct the code to fix the problem
14-
// =============> write your new code here
17+
// =============> write your new code here:
18+
function multiply(a, b) {
19+
return a * b;
20+
}
21+
22+
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);

0 commit comments

Comments
 (0)