You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//I think that the problem is our function multiply does not return any value but write in console
5
+
// However, we are calling the function inside another console.log and expecting the function to return some value.
4
6
5
7
functionmultiply(a,b){
6
8
console.log(a*b);
7
9
}
8
10
9
11
console.log(`The result of multiplying 10 and 32 is ${multiply(10,32)}`);
10
12
11
-
// =============> write your explanation here
13
+
// =============> Yeah, when we run the code we get the following output which shows that second console is not able to get the value from the function as the function does not return any value.
14
+
/*
15
+
320
16
+
The result of multiplying 10 and 32 is undefined
17
+
*/
12
18
13
19
// Finally, correct the code to fix the problem
14
20
// =============> write your new code here
21
+
/*
22
+
function multiply(a, b) {
23
+
return a * b;
24
+
}
25
+
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
// In the below function, after return there is a semi colon which syntactically would just return nothing and any line of code below that would not run
4
4
functionsum(a,b){
5
5
return;
6
6
a+b;
@@ -9,5 +9,12 @@ function sum(a, b) {
9
9
console.log(`The sum of 10 and 32 is ${sum(10,32)}`);
@@ -17,18 +19,18 @@ function formatTimeDisplay(seconds) {
17
19
// Questions
18
20
19
21
// a) When formatTimeDisplay is called how many times will pad be called?
20
-
// =============> write your answer here
22
+
// =============> 3
21
23
22
24
// Call formatTimeDisplay with an input of 61, now answer the following:
23
25
24
26
// b) What is the value assigned to num when pad is called for the first time?
25
-
// =============> write your answer here
27
+
// =============> 0
26
28
27
29
// c) What is the return value of pad is called for the first time?
28
-
// =============> write your answer here
30
+
// =============> 00
29
31
30
32
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
31
-
// =============> write your answer here
33
+
// =============> Value assigned to num is '1' i.e. the value fo remaining seconds. As when in the program we did seconds % 60 we got the remaining seconds as 1
32
34
33
35
// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
34
-
// =============> write your answer here
36
+
// =============> the value assigned is '01' because when the function pad is called on the value 1, the padStart method inside that function applies the pad length of 2 using 0.
0 commit comments