File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
Sprint-2/2-mandatory-debug Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change 11// Predict and explain first...
22// =============> write your prediction here
3+ // Output: "The sum of 10 and 32 is undefined"
4+ // Return statement has no value, so returns undefined. Expression "a + b" is unreachable code
35
46function sum ( a , b ) {
57 return ;
@@ -9,5 +11,11 @@ function sum(a, b) {
911console . log ( `The sum of 10 and 32 is ${ sum ( 10 , 32 ) } ` ) ;
1012
1113// =============> write your explanation here
14+ // Bug: return; exits immediately without a value (returns undefined). Code after return never executes
15+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return
16+
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+ }
You can’t perform that action at this time.
0 commit comments