File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Sprint-2/2-mandatory-debug Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 11// Predict and explain first...
22// =============> write your prediction here
3+ // It looks like the function sum return nothing because a+b is written in the next line after return statement.
4+ // Therefore, the output should be "The sum of 10 and 32 is undefined".
35
6+ /*
47function sum(a, b) {
58 return;
69 a + b;
710}
811
912console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
10-
13+ */
1114// =============> write your explanation here
15+ // After running the code, I got "The sum of 10 and 32 is undefined".
16+ // The return statement ends the function execution and a+b is never evaluated.
17+
1218// Finally, correct the code to fix the problem
1319// =============> write your new code here
20+ function sum ( a , b ) {
21+ return a + b ;
22+ }
23+ console . log ( `The sum of 10 and 32 is ${ sum ( 10 , 32 ) } ` ) ; // should return "The sum of 10 and 32 is 42"
You can’t perform that action at this time.
0 commit comments