Skip to content

Commit 43cff66

Browse files
committed
explain error
1 parent 5d023b1 commit 43cff66

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(a*b) is inside the function, so it does not return anything instead return undefined by default
44

55
function multiply(a, b) {
66
console.log(a * b);
77
}
88

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

11-
// =============> write your explanation here
11+
// =============> When we call multiply(10, 32) inside the template string, it first runs console.log(320) inside the function.
12+
// Then it tries to insert the function’s return value (which is undefined) into the string.
13+
// So, we’ll see:csharp
14+
// Copy
15+
// Edit
16+
// 320
17+
// The result of multiplying 10 and 32 is undefined
1218

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

0 commit comments

Comments
 (0)