File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Sprint-2/2-mandatory-debug Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 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
56function multiply ( a , b ) {
67 console . log ( a * b ) ;
78}
89
910console . 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 ) } ` ) ;
You can’t perform that action at this time.
0 commit comments