File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Sprint-2/2-mandatory-debug Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 11// Predict and explain first...
22
33// =============> write your prediction here
4+ // I predict that the console will log `320` first (from inside the function),
5+ // but then the message will say: "The result of multiplying 10 and 32 is undefined".
6+
7+ // Explanation:
48
59function multiply ( a , b ) {
610 console . log ( a * b ) ;
@@ -9,6 +13,16 @@ function multiply(a, b) {
913console . log ( `The result of multiplying 10 and 32 is ${ multiply ( 10 , 32 ) } ` ) ;
1014
1115// =============> write your explanation here
16+ // The function `multiply` logs the result of `a * b`, but does not return it.
17+ // When it's used inside a template literal, JavaScript evaluates `multiply(10, 32)` as `undefined`,
18+ // because the function has no return value. That's why we get:
19+ // `The result of multiplying 10 and 32 is undefined` — even though `320` is logged separately.
1220
1321// Finally, correct the code to fix the problem
1422// =============> write your new code here
23+
24+ function multiply ( a , b ) {
25+ return a * b ;
26+ }
27+
28+ console . log ( `The result of multiplying 10 and 32 is ${ multiply ( 10 , 32 ) } ` ) ;
You can’t perform that action at this time.
0 commit comments