Skip to content

Commit 4919640

Browse files
committed
fix code, write explanation
1 parent 4b743c8 commit 4919640

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

  • Sprint-2/2-mandatory-debug

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

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

33
// =============> write your prediction here
4-
5-
function multiply(a, b) {
4+
//===========Prediction=======
5+
// I think the code will not produce the desired result as the function is not returning any value
6+
/*function multiply(a, b) {
67
console.log(a * b);
78
}
8-
99
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
10+
console.log(multiply(3, 5));
11+
typeof(multiply(3, 4));*/
1012

1113
// =============> write your explanation here
12-
14+
//===============Explanation=========
15+
// The function itself prints out the result, but the result has no (type) as such and can not be used as
16+
// a data type.
17+
//
1318
// Finally, correct the code to fix the problem
19+
//============correction============
20+
// To correct the code "return" needs to be introduced.
1421
// =============> write your new code here
22+
function multiply(a, b) {
23+
return (a * b);
24+
}
25+
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);

0 commit comments

Comments
 (0)