Skip to content

Commit a10df18

Browse files
authored
erased first console.log and replaced it with 'return' to properly log the result.
Changed console.log to return in multiply function to fix undefined error.
1 parent 02c8367 commit a10df18

File tree

1 file changed

+15
-6
lines changed
  • Sprint-2/2-mandatory-debug

1 file changed

+15
-6
lines changed

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

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

3-
// =============> write your prediction here
3+
// =============> write your prediction here: there will be an error, due to console.log being used incorrectly. Console.log is for displaying but there is no return command to
4+
//clarify what to send to console.log
5+
6+
//function multiply(a, b) {
7+
// console.log(a * b);
8+
//}
9+
10+
//console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
11+
12+
// =============> write your explanation here: I have run the code on node.js and got 'undefined' as an error message. I shall add 'return' instead of the first 'console.log'
13+
//so that the result can be displayed properly in the second console.log.
14+
15+
// Finally, correct the code to fix the problem
16+
// =============> write your new code here:
417

518
function multiply(a, b) {
6-
console.log(a * b);
19+
return a * b;
720
}
821

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

11-
// =============> write your explanation here
12-
13-
// Finally, correct the code to fix the problem
14-
// =============> write your new code here

0 commit comments

Comments
 (0)