Skip to content

Commit f59d4fc

Browse files
committed
Explain each line of the multiply function
1 parent b639581 commit f59d4fc

File tree

1 file changed

+14
-1
lines changed
  • Sprint-2/2-mandatory-debug

1 file changed

+14
-1
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// =============> write your prediction here
44
// Answer
5-
// If this program runs, I predict that the function will return undefined because no return statement is defined inside the function.
5+
// If this program runs, I predict that the function will return undefined because it has no return statement.
66
// Also, the console.log inside the multiply function will print its output to the terminal.
77
// Lastly, because the function returns undefined, when ${multiply(10, 32)} is used inside a template literal inside the console.log function, it will print undefined in that position.
88

@@ -13,6 +13,19 @@
1313
//console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
1414

1515
// =============> write your explanation here
16+
// Explanation
17+
// function multiply(a, b) {}
18+
// This expression defines a function named multiply.
19+
// The function takes two parameters: a and b.
20+
21+
// console.log(a * b);
22+
// This expression multipies a and b and prints the result in the terminal.
23+
// There is no return statement, so the function implicitly returns undefined.
24+
25+
// console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
26+
// In this expression, multiply(10, 32) is called.
27+
// Because the function returns undefined, the template literal becomes: "The result of multiplying 10 and 32 is undefined"
28+
// That string is printed to the console.
1629

1730
// Finally, correct the code to fix the problem
1831
// =============> write your new code here

0 commit comments

Comments
 (0)