Skip to content

Commit 516822d

Browse files
committed
function was not returned to global scope
1 parent 1564427 commit 516822d

File tree

1 file changed

+12
-3
lines changed
  • Sprint-2/2-mandatory-debug

1 file changed

+12
-3
lines changed

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

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

3-
// =============> write your prediction here
3+
// console.log is being used inside the multiply function, which does not return any value.
4+
// This will result in undefined being printed in the template literal.
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+
// Output in the terminal was: "320
13+
// The result of multiplying 10 and 32 is undefined"
14+
// Console.log within the function prints the product of the calculation, but the function does not return the value to the global scope.
15+
// Therefore within the template literal, the meaning of the multiply function call is undefined
1216

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

0 commit comments

Comments
 (0)