File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed
Sprint-2/2-mandatory-debug Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change 1
- // Predict and explain first...
2
-
3
1
// =============> write your prediction here
2
+ // function multiply(a, b) {
3
+ // console.log(a * b);
4
+ // }
4
5
5
- function multiply ( a , b ) {
6
- console . log ( a * b ) ;
7
- }
6
+ // console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
8
7
9
- console . log ( `The result of multiplying 10 and 32 is ${ multiply ( 10 , 32 ) } ` ) ;
8
+ // The output will be:
9
+ // 320
10
+ // The result of multiplying 10 and 32 is undefined
11
+ // This is because multiply logs the result but does not return it, so the template literal gets undefined.
10
12
11
13
// =============> write your explanation here
14
+ // The function multiply only prints the result to the console and does not return anything.
15
+ // When we use multiply(10, 32) inside the template literal, it evaluates to undefined because the function has no return value.
16
+
12
17
13
18
// Finally, correct the code to fix the problem
14
19
// =============> write your new code here
20
+ function multiply ( a , b ) {
21
+ return a * b ;
22
+ }
23
+
24
+ console . log ( `The result of multiplying 10 and 32 is ${ multiply ( 10 , 32 ) } ` ) ;
You can’t perform that action at this time.
0 commit comments