Skip to content

Commit f08d00a

Browse files
committed
Predict program behavior and provide corrected code
- Predict what will happen when the program runs. - Write the correct code to fix any errors.
1 parent b509c65 commit f08d00a

File tree

1 file changed

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

1 file changed

+14
-4
lines changed

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

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

33
// =============> write your prediction here
4+
// Answer
5+
// If this program runs, I predict that the function will return undefined because no return statement is defined inside the function.
6+
// Also, the console.log inside the multiply function will print its output to the terminal.
7+
// Lastly, because the function returns undefined, when ${multiply(10, 32)} is used inside a template literal inside the console.log function, it will print undefined in that position.
48

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

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

1115
// =============> write your explanation here
1216

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

0 commit comments

Comments
 (0)