Skip to content

Commit 95b56ec

Browse files
committed
function return corrected
1 parent 516822d commit 95b56ec

File tree

1 file changed

+9
-3
lines changed
  • Sprint-2/2-mandatory-debug

1 file changed

+9
-3
lines changed

Sprint-2/2-mandatory-debug/1.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
// a + b should be written on the same line as return statement
3+
// This function will not return anything because of the semicolon, so when the function is call on line 10 it will be undefined.
34

45
function sum(a, b) {
56
return;
@@ -8,6 +9,11 @@ function sum(a, b) {
89

910
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
1011

11-
// =============> write your explanation here
12+
// Terminal output "The sum of 10 and 32 is undefined"
13+
// Console.log is calling a function that was not defined because the function body has an incorrect return statement.
14+
1215
// Finally, correct the code to fix the problem
13-
// =============> write your new code here
16+
function sum(a, b) {
17+
return a + b;
18+
}
19+
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);

0 commit comments

Comments
 (0)