File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Sprint-2/2-mandatory-debug Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 11// Predict and explain first...
22
33// =============> write your prediction here
4-
4+ // It seems the function multiply did not return any value.
5+ // Therefore, it is like a console.log returning undefined, while it is inside another console.log.
6+ // So the output should be "The result of multiplying 10 and 32 is undefined".
7+ /*
58function multiply(a, b) {
69 console.log(a * b);
710}
811
912console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
10-
13+ */
1114// =============> write your explanation here
15+ // After running the code, I got a separate output of 320 and "The result of multiplying 10 and 32 is undefined".
16+ // This is because the function multiply does not return any value, so it returns undefined by default.
17+ // The console.log inside the function multiply prints 320 when the function is called.
1218
1319// Finally, correct the code to fix the problem
1420// =============> write your new code here
21+ function multiply ( a , b ) {
22+ return a * b ;
23+ }
24+ console . log ( `The result of multiplying 10 and 32 is ${ multiply ( 10 , 32 ) } ` ) ; // should return "The result of multiplying 10 and 32 is 320"
You can’t perform that action at this time.
0 commit comments