Skip to content

Commit cc216e1

Browse files
committed
added a return to the function
1 parent 0c7cc6f commit cc216e1

File tree

1 file changed

+11
-4
lines changed
  • Sprint-2/2-mandatory-debug

1 file changed

+11
-4
lines changed

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

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

33
// =============> write your prediction here
4+
//line 7 will log the result of a * b, line 10 will throw an error since the function does not return anything so it will say The result of multiplying 10 and 32 is undefined.
45

5-
function multiply(a, b) {
6-
console.log(a * b);
7-
}
6+
//function multiply(a, b) {
7+
// console.log(a * b);
8+
//}
89

9-
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
10+
//console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
1011

1112
// =============> write your explanation here
13+
//since the function does not return a value we get undefined passed back to the console.
1214

1315
// Finally, correct the code to fix the problem
1416
// =============> write your new code here
17+
function multiply(a, b) {
18+
return a * b;
19+
}
20+
21+
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);

0 commit comments

Comments
 (0)