Skip to content

Commit 5ae96f4

Browse files
authored
Answering the required questions and testing the code
1 parent dd95e03 commit 5ae96f4

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Sprint-1/3-mandatory-interpret/2-time-format.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,52 @@ console.log(result);
1212
// For the piece of code above, read the code and then answer the following questions
1313

1414
// a) How many variable declarations are there in this program?
15+
/* There are 6 variable declarations:
16+
1.Line 1 : const movieLength.
17+
2.Line 3 : const remainingSeconds.
18+
3.Line 4 : const totalMinutes.
19+
4.Line 6 : const remainingMinutes.
20+
5.Line 7 : const totalHours.
21+
6.Line 9 : const result.
22+
*/
1523

1624
// b) How many function calls are there?
1725

26+
/* There is one function call:
27+
Line 10 : console.log().
28+
*/
29+
1830
// c) Using documentation, explain what the expression movieLength % 60 represents
31+
32+
/* The movieLength represents the length of the movie in seconds, the operand % is remaining (Modulo) returns the remaining of the movieLength divided by 60(to convert sec into minutes) but it only gives the remaining of this operation.
33+
*/
34+
1935
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
2036

2137
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
2238

39+
/*
40+
The expression assigned to completed total minutes of the movie, by subtract the movie length in sec from the remaining seconds and divide the result by 60 to convert it to minutes
41+
*/
42+
2343
// e) What do you think the variable result represents? Can you think of a better name for this variable?
2444

45+
/*
46+
The variable result display the total length of the movie in these form (Hours:Minutes:seconds) in string format.
47+
48+
I can think of "MovieDuration" as a better name because it gives more description to the output.
49+
*/
50+
2551
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
52+
53+
/*
54+
I did experimenting the code by putting different value to the movieLength and it works just fine.
55+
56+
test numbers and its outcomes:
57+
1. 36000sec>> 10:0:0
58+
2. 120 sec >> 0:2:0
59+
3. 0 sec >> 0:0:0
60+
4. 555555.55sec >> 154:19:15.550000000046566
61+
62+
As the results show the code is working fine even with unexpected large numbers.
63+
*/

0 commit comments

Comments
 (0)