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 guess that the output will be undefined because there is a semicolon after the "return" and this breaks the line of code, and after return statement nothing can be returned
3
3
4
-
functionsum(a,b){
5
-
return;
6
-
a+b;
7
-
}
4
+
// function sum(a, b) {
5
+
// return;
6
+
// a + b;
7
+
// }
8
8
9
-
console.log(`The sum of 10 and 32 is ${sum(10,32)}`);
9
+
// console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
10
10
11
11
// =============> The output is "The sum of 10 and 32 is undefined" as I predicted above
12
12
// Finally, correct the code to fix the problem
13
-
// =============> function sum(a, b) {
14
-
// return a + b;
15
-
// }
13
+
functionsum(a,b){
14
+
returna+b;
15
+
}
16
+
17
+
console.log(`The sum of 10 and 32 is ${sum(10,32)}`);
// I found that when I added minutes, the output became incorrect because the original function only changed the hours. I fixed this bug by introducing a new variable called minutes and using it as the second part of the output after the hours. I also added some formatting for the minutes and defined the period of time (am/pm) in a variable called timeSuffix to make the output display correctly.
0 commit comments