Skip to content

Commit 689ea33

Browse files
committed
Predicted, explained and fixed code errors
1 parent cd6e897 commit 689ea33

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

  • Sprint-3/2-mandatory-debug

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

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

33
// =============> write your prediction here
4+
// It will print 2 lines:
5+
// (10*32=320) line 1: 320
6+
// line 2: The result of multiplying 10 and 32 is undefined
47

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

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

1114
// =============> write your explanation here
15+
// There are two console.log() being called.
16+
// The one inside the funtion prints the result of the multiplication
17+
// The one outside the function prints the desired result of the whole string but there is no return from the function so it is undefined
18+
// The result of multiplying 10 and 32 is undefined.
1219

1320
// Finally, correct the code to fix the problem
1421
// =============> write your new code here
22+
function multiply(a, b) {
23+
return a * b;
24+
}
25+
26+
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);

0 commit comments

Comments
 (0)