File tree Expand file tree Collapse file tree
Sprint-3/2-mandatory-debug Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11// Predict and explain first...
22
33// =============> write your prediction here
4+ // I predict it will print 320 first (from the console.log inside multiply),
5+ // and then "The result of multiplying 10 and 32 is undefined", because
6+ // multiply does not return a value.
47
58function multiply ( a , b ) {
6- console . log ( a * b ) ;
9+ return ( a * b ) ;
710}
811
912console . log ( `The result of multiplying 10 and 32 is ${ multiply ( 10 , 32 ) } ` ) ;
1013
1114// =============> write your explanation here
15+ // multiply only logs a * b to the console. It has no return statement, so
16+ // multiply(10, 32) evaluates to undefined. The template string on line 12
17+ // puts that undefined into the sentence. The 320 appears on its own line
18+ // because console.log runs inside the function.
1219
1320// Finally, correct the code to fix the problem
1421// =============> write your new code here
22+ // I changed console.log(a * b) to return a * b inside multiply, so the
23+ // function hands the result back to the caller instead of only printing it.
You can’t perform that action at this time.
0 commit comments