Skip to content

Commit e11ca35

Browse files
predicted the the program will not work because the function will not return a value and changed the console.log inside the function into return instead.
1 parent e3e39a8 commit e11ca35

File tree

1 file changed

+17
-0
lines changed
  • Sprint-2/2-mandatory-debug

1 file changed

+17
-0
lines changed

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

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

33
// =============> write your prediction here
4+
// I prediact that the error will occur because the function multiply does not return any value and this will make the console.log function to print undefined instead.
5+
46

57
function multiply(a, b) {
68
console.log(a * b);
@@ -9,6 +11,21 @@ function multiply(a, b) {
911
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
1012

1113
// =============> write your explanation here
14+
// when the program run it give this output:
15+
16+
// 320
17+
// The result of multiplying 10 and 32 is undefined
18+
19+
// 320: the out put for the console.log inside the function
20+
21+
// while the ouout the out put for the console.log function out of the function returned the string provided in the function and an undefiened because the function multibly doesn't return any value.
22+
// to fix this error we need to change the console.log function inside the function to return.
23+
1224

1325
// Finally, correct the code to fix the problem
1426
// =============> write your new code here
27+
function multiply(a, b) {
28+
return a * b;
29+
}
30+
31+
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);

0 commit comments

Comments
 (0)