Skip to content

Commit dde5917

Browse files
fix: update multiply function to return the product instead of logging it and updated comments
1 parent 2a18e2c commit dde5917

File tree

1 file changed

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

1 file changed

+12
-2
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
// Predict and explain first...
2+
// I expect the code to log the results of multiplying 10 and 32 but in line 10 i expect it to return undefined because the function "multiply" does not have a return statement.
23

34
// =============> write your prediction here
4-
5+
/*
56
function multiply(a, b) {
67
console.log(a * b);
78
}
89
910
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
10-
11+
*/
1112
// =============> write your explanation here
13+
// The code defines a function "multiply" that takes two parameters "a" and "b" and logs their product to the console. However, it does not return any value from the function.
14+
// The function `multiply` is called with arguments 10 and 32, but since it does not return a value, the template literal will log "undefined" for the result of the multiplication.
15+
// and to fix this, the function should return the product instead of just logging it.
16+
1217

1318
// Finally, correct the code to fix the problem
1419
// =============> write your new code here
20+
21+
function multiply(a, b){
22+
return a * b; // Return the product instead of logging it
23+
}
24+
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`); // now this will log the correct results

0 commit comments

Comments
 (0)