Skip to content

Commit 58aa840

Browse files
committed
update: Fix multiply function to return the product of two numbers and explain function for clarity in Sprint-2/2-mandatory-debug/0.js
1 parent 1b1b8c9 commit 58aa840

File tree

1 file changed

+18
-2
lines changed
  • Sprint-2/2-mandatory-debug

1 file changed

+18
-2
lines changed

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

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

3+
// The code below is intended to multiply two numbers and log the result.
4+
// However, it currently does not return the result correctly.
5+
// The function `multiply` is defined to take two parameters `a` and `b`.
6+
// It logs the product of `a` and `b` but does not return it.
7+
// The console.log statement outside the function attempts to log the result of calling `multiply(10, 32)`.
8+
// The expected output is "The result of multiplying 10 and 32 is 320".
9+
// However, since `multiply` does not return a value, the output will be "The result of multiplying 10 and 32 is undefined".
310
// =============> write your prediction here
411

512
function multiply(a, b) {
6-
console.log(a * b);
13+
// This function multiplies two numbers and logs the result
14+
// but does not return it.
15+
// It should return the product instead of just logging it.
16+
// The current implementation will not return the product.
17+
//console.log(a * b);
18+
// This line should be changed to return the product
19+
return a * b; // Corrected to return the product
720
}
821

922
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
10-
1123
// =============> write your explanation here
24+
// // The code is intended to multiply two numbers and log the result.
25+
// However, it currently does not return the result correctly.
26+
// The expected output is "The result of multiplying 10 and 32 is 320".
27+
// The current output will be "The result of multiplying 10 and 32 is undefined".
1228

1329
// Finally, correct the code to fix the problem
1430
// =============> write your new code here

0 commit comments

Comments
 (0)