File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
Sprint-2/2-mandatory-debug Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change 11// Predict and explain first...
22// =============> write your prediction here
3+ // When the code is run the console log will show undefined because the function returns before the sum is calculated
4+ // function sum(a, b) {
5+ // return;
6+ // a + b;
7+ // }
38
4- function sum ( a , b ) {
5- return ;
6- a + b ;
7- }
8-
9- console . log ( `The sum of 10 and 32 is ${ sum ( 10 , 32 ) } ` ) ;
9+ // console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
1010
1111// =============> write your explanation here
12+ // When a return statement is reached the function exits immediately. Therefore the line a + b is never executed and the function returns undefined.
1213// Finally, correct the code to fix the problem
1314// =============> write your new code here
15+ function sum ( a , b ) {
16+ return a + b ;
17+ }
18+
19+ console . log ( `The sum of 10 and 32 is ${ sum ( 10 , 32 ) } ` ) ;
You can’t perform that action at this time.
0 commit comments