File tree Expand file tree Collapse file tree
Sprint-2/2-mandatory-debug Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- // Predict and explain first...
2- // =============> write your prediction here
1+ // Predict and explain first...
2+ // =============> write your prediction here
3+ // I predict that the function will not return undefined.
4+ // This is due to the fact that the return statement is on its own line, therefore trying to do the addition will not work as the code is not read.
35
4- function sum ( a , b ) {
5- return ;
6- a + b ;
7- }
6+ function sum ( a , b ) {
7+ return ;
8+ a + b ;
9+ }
810
9- console . log ( `The sum of 10 and 32 is ${ sum ( 10 , 32 ) } ` ) ;
11+ console . log ( `The sum of 10 and 32 is ${ sum ( 10 , 32 ) } ` ) ;
1012
11- // =============> write your explanation here
12- // Finally, correct the code to fix the problem
13- // =============> write your new code here
13+ // =============> write your explanation here
14+ // The return statement is written on its own line, therefore JS automatically inserts a semicolon after the return.
15+ // This means that the function exits immediately and returns undefined.
16+ // The expression a + b; is not executed.
17+
18+ // Finally, correct the code to fix the problem
19+ // =============> write your new code here
20+ function sum ( a , b ) {
21+ return a + b ;
22+ }
23+
24+ console . log ( `The sum of 10 and 32 is ${ sum ( 10 , 32 ) } ` ) ;
You can’t perform that action at this time.
0 commit comments