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 33d07a2
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: Sprint-3/2-mandatory-debug/1.js
+12-7Lines changed: 12 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,18 @@
1
1
// Predict and explain first...
2
2
// The function will not return the expected result because whilst sum takes in two arguments it cannot add a+b together because it hasn't been stored in a variable before return so when we call sum it will be undefined?
3
3
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)}`);
10
+
//console output: The sum of 10 and 32 is undefined
11
+
// sum is undefined because we haven't stored the operation we want it to perform correctly in a variable so its value is undefined.
12
+
// Finally, correct the code to fix the problem
13
+
4
14
functionsum(a,b){
5
-
return;
6
-
a+b;
15
+
letsumResult=a+b;
16
+
returnsumResult;
7
17
}
8
-
9
18
console.log(`The sum of 10 and 32 is ${sum(10,32)}`);
0 commit comments