Skip to content

Commit cb0e8e3

Browse files
committed
explained the log message and fixed the code
1 parent 77b2288 commit cb0e8e3

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

  • Sprint-3/2-mandatory-debug

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@
22

33
// here we are declaring a function called multiply which takes in two arguments and multiplies them but because the function doesn't return the value when we call the function it hasnt been stored anywhere for it to be called upon so i think it will return undefined in the template literal. I also think because there are two console logs one will print the value 320 and the other will print the template literal but as multiply hasn't been stored anywhere it will print undefined ?
44

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

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

11-
// =============> write your explanation here
11+
//320
12+
//The result of multiplying 10 and 32 is undefined
13+
// the function as it is only storing the result of a and b in two console logs one asking for the total which is 320 so it prints it and the other is template literal so it prints the template literal but multiply is undefined.
1214

1315
// Finally, correct the code to fix the problem
14-
// =============> write your new code here
16+
function multiply(a, b) {
17+
let multiplyResult = a * b;
18+
return multiplyResult;
19+
}
20+
21+
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);

0 commit comments

Comments
 (0)