You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0e0827d
Browse filesBrowse the repository at this point in the historyBrowse files
// I predict that the code will run but it will print undefined because the return expression is not setup properly
3
3
4
-
functionsum(a,b){
4
+
/*function sum(a, b) {
5
5
return;
6
6
a + b;
7
7
}
8
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)}`);*/
10
+
11
+
// When we run the code it printed out undefined because the return keyword is there but the expression that needs to be returned is not on the same line
12
+
// therefore the return keyword can't reach the expression and the expression is ignored because the function has done execution right after it reaches the return keyword
10
13
11
-
// =============> write your explanation here
12
14
// Finally, correct the code to fix the problem
13
-
// =============> write your new code here
15
+
// Here is the fixed code
16
+
17
+
functionsum(a,b){
18
+
returna+b;
19
+
}
20
+
21
+
console.log(`The sum of 10 and 32 is ${sum(10,32)}`);
0 commit comments