File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed
Sprint-2/2-mandatory-debug Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change 1
1
// Predict and explain first...
2
2
// =============> write your prediction here
3
+ // function sum(a, b) {
4
+ // return;
5
+ // a + b;
6
+ // }
3
7
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 ) } ` ) ;
8
+ // console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
9
+ // The output will be: The sum of 10 and 32 is undefined
10
+ // This is because the function returns immediately with no value, so a + b is never executed.
10
11
11
12
// =============> write your explanation here
13
+ // The return statement ends the function before a + b is calculated, so the function returns undefined.
14
+
12
15
// Finally, correct the code to fix the problem
13
16
// =============> write your new code here
17
+ function sum ( a , b ) {
18
+ return a + b ;
19
+ }
20
+
21
+ console . log ( `The sum of 10 and 32 is ${ sum ( 10 , 32 ) } ` ) ;
You can’t perform that action at this time.
0 commit comments