Skip to content

Commit 3f9d9b6

Browse files
predict explain and fix code
1 parent 4c0e0eb commit 3f9d9b6

File tree

1 file changed

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

1 file changed

+20
-3
lines changed

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

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

3-
// =============> write your prediction here
3+
// =============> when the console.log outside the function is performed $(multiply(10, 32))
4+
// it will print the text The result of multiplying by 10 and 32 is
5+
// but then will state undefined for the value
6+
47

58
function multiply(a, b) {
69
console.log(a * b);
710
}
811

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

11-
// =============> write your explanation here
14+
// =============> there is no return
15+
// console.log(a*B) printed the result of multiplying a and b but because there is no return
16+
// the answer was not returned to the function so the console.log outside the function did not
17+
// receive the value and printed undefined instead
18+
1219

1320
// Finally, correct the code to fix the problem
14-
// =============> write your new code here
21+
// =============>
22+
// function multiply(a, b) {
23+
// return a * b;
24+
// }
25+
// console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
26+
27+
// I removed the first console.log because it didn't seem necessary to print out 320
28+
// if you need to print 320 as well as the final console-log statement then console.log(a * b)
29+
// can be added back in but it would need to be before the return statement because if it is
30+
// after the return statement it will never be reached and the value will not be printed out
31+

0 commit comments

Comments
 (0)