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...
2- // =============> write your prediction here
2+ // =============> write your prediction here:This is the error:The sum of 10 and 32 is undefined.
3+ // The code will run without a syntax error, but it will return undefined instead of 42.
34
45function sum ( a , b ) {
56 return ;
@@ -8,6 +9,15 @@ function sum(a, b) {
89
910console . log ( `The sum of 10 and 32 is ${ sum ( 10 , 32 ) } ` ) ;
1011
11- // =============> write your explanation here
12+ // =============> write your explanation here:
13+ //The problem is that return; immediately ends the function://return;
14+ //a + b;
15+
16+ //if we write anything after return(next line)is unreachable, so a + b doesn't run. The function therefore returns undefined.
1217// Finally, correct the code to fix the problem
1318// =============> write your new code here
19+ function sum ( a , b ) {
20+ return a + b ;
21+ }
22+
23+ console . log ( `The sum of 10 and 32 is ${ sum ( 10 , 32 ) } ` ) ;
You can’t perform that action at this time.
0 commit comments