Skip to content

Commit 62255c0

Browse files
Debug return value
1 parent 53921fe commit 62255c0

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

  • Sprint-3/2-mandatory-debug

‎Sprint-3/2-mandatory-debug/0.js‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
// Predict and explain first...
22

33
// =============> write your prediction here
4+
// I believe the function will calculate 10 x 32
45

56
function multiply(a, b) {
67
console.log(a * b);
8+
79
}
810

911
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
1012

1113
// =============> write your explanation here
1214

15+
// After calling multiply(10, 32), the result is undefined because there is no return statement
16+
// It can still print 320 because console.log() prints the result inside the function
17+
1318
// Finally, correct the code to fix the problem
1419
// =============> write your new code here
20+
21+
function multiply(a, b) {
22+
console.log(a * b);
23+
return a * b;
24+
}
25+
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);

0 commit comments

Comments
 (0)