There was an error while loading. Please reload this page.
1 parent 7b557c2 commit 5d7a4cfCopy full SHA for 5d7a4cf
1 file changed
Sprint-3/2-mandatory-debug/1.js
@@ -1,5 +1,6 @@
1
// Predict and explain first...
2
// =============> write your prediction here
3
+// Output: The sum of 10 and 32 is undefined
4
5
function sum(a, b) {
6
return;
@@ -9,5 +10,12 @@ function sum(a, b) {
9
10
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
11
12
// =============> write your explanation here
13
+// Because there is no value after `return`, the function returns undefined.
14
+// The line a + b is unreachable code, meaning it will never run.
15
// Finally, correct the code to fix the problem
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)}`);
0 commit comments