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// =============> write your prediction here
3+ // I predict it will print "The sum of 10 and 32 is undefined", because
4+ // the function returns before it reaches a + b.
35
46function sum ( a , b ) {
5- return ;
6- a + b ;
7+ return a + b ;
78}
89
910console . log ( `The sum of 10 and 32 is ${ sum ( 10 , 32 ) } ` ) ;
1011
1112// =============> write your explanation here
13+ // The return statement was on its own line with nothing after it, so the
14+ // function returned undefined straight away. JavaScript treats the line
15+ // break after return as the end of the statement, so a + b on the next
16+ // line was never reached.
1217// Finally, correct the code to fix the problem
1318// =============> write your new code here
19+ // I moved a + b onto the same line as return: return a + b
You can’t perform that action at this time.
0 commit comments