Skip to content

Commit de47a6e

Browse files
committed
fix(sprint-2): add return statement to multiply function
1 parent f3dab49 commit de47a6e

File tree

1 file changed

+7
-0
lines changed
  • Sprint-2/2-mandatory-debug

1 file changed

+7
-0
lines changed

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

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

33
// =============> write your prediction here
4+
// Output: "320" then "The result of multiplying 10 and 32 is undefined"
5+
// Function logs but doesn't return, so template literal receives undefined
46

57
function multiply(a, b) {
68
console.log(a * b);
@@ -9,6 +11,11 @@ function multiply(a, b) {
911
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
1012

1113
// =============> write your explanation here
14+
// Bug: console.log() prints but doesn't return a value - functions without return give undefined
15+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return
1216

1317
// Finally, correct the code to fix the problem
1418
// =============> write your new code here
19+
function multiply(a, b) {
20+
return a * b;
21+
}

0 commit comments

Comments
 (0)