Skip to content

Commit db6578c

Browse files
committed
0.js
1 parent fcb215c commit db6578c

File tree

1 file changed

+16
-6
lines changed
  • Sprint-2/2-mandatory-debug

1 file changed

+16
-6
lines changed

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
1-
// Predict and explain first...
2-
31
// =============> write your prediction here
2+
// function multiply(a, b) {
3+
// console.log(a * b);
4+
// }
45

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

9-
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
8+
// The output will be:
9+
// 320
10+
// The result of multiplying 10 and 32 is undefined
11+
// This is because multiply logs the result but does not return it, so the template literal gets undefined.
1012

1113
// =============> write your explanation here
14+
// The function multiply only prints the result to the console and does not return anything.
15+
// When we use multiply(10, 32) inside the template literal, it evaluates to undefined because the function has no return value.
16+
1217

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

0 commit comments

Comments
 (0)