File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed
Sprint-2/2-mandatory-debug Expand file tree Collapse file tree 1 file changed +20
-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+ // =============> when the console.log outside the function is performed $(multiply(10, 32))
4+ // it will print the text The result of multiplying by 10 and 32 is
5+ // but then will state undefined for the value
6+
47
58function multiply ( a , b ) {
69 console . log ( a * b ) ;
710}
811
912console . log ( `The result of multiplying 10 and 32 is ${ multiply ( 10 , 32 ) } ` ) ;
1013
11- // =============> write your explanation here
14+ // =============> there is no return
15+ // console.log(a*B) printed the result of multiplying a and b but because there is no return
16+ // the answer was not returned to the function so the console.log outside the function did not
17+ // receive the value and printed undefined instead
18+
1219
1320// Finally, correct the code to fix the problem
14- // =============> write your new code here
21+ // =============>
22+ // function multiply(a, b) {
23+ // return a * b;
24+ // }
25+ // console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
26+
27+ // I removed the first console.log because it didn't seem necessary to print out 320
28+ // if you need to print 320 as well as the final console-log statement then console.log(a * b)
29+ // can be added back in but it would need to be before the return statement because if it is
30+ // after the return statement it will never be reached and the value will not be printed out
31+
You can’t perform that action at this time.
0 commit comments