Skip to content

Commit 96f2e35

Browse files
committed
Exercise 3-time-format solved
1 parent ecc906b commit 96f2e35

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const movieLength = 8784; // length of movie in seconds
1+
const movieLength = 86399; // length of movie in seconds
22

33
const remainingSeconds = movieLength % 60;
44
const totalMinutes = (movieLength - remainingSeconds) / 60;
@@ -12,14 +12,30 @@ 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.
1516

1617
// b) How many function calls are there?
18+
// There is only 1 function call.
1719

1820
// c) Using documentation, explain what the expression movieLength % 60 represents
1921
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
22+
// this expression divided the movie length (is seconds) by 60 so we get how many minutes the movie length is.
23+
// but since we used % not / that means we only took the reminder left over after dividing the number.
24+
// so basically the code identifies how many seconds will be left over after getting the minutes amount.
2025

2126
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
27+
// it means that the result of this expression will be the total minutes of the video.
28+
// before that - in line 3 - it took the number of seconds left, and in line 4 it divides the
29+
// movie length ( takes the remaining seconds out ) by 60 because a minute contains 60 seconds.
30+
// so it actually converts the seconds into minutes.
2231

2332
// e) What do you think the variable result represents? Can you think of a better name for this variable?
33+
// The output of the variable result represents time (period of the movie).
34+
// it actually shows the result of converting seconds into readable time format.
35+
// Better to call it (ReadableMovieTime).
2436

2537
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
38+
// It does work with most if the values, BUT if I put a number that's bigger than 86399, which returns: 23:59:59
39+
// that means it ignores the days, it can be mediated so it can count days, months and years.
40+
// I haven't watched a movie that is longer than a day but just in case :), I think the code should be kind of general sometimes!!
41+
// Also two zeros should be displayed if there're not hours or mins (when I put small numbers that are less that an hour), so it gets more understandable.

0 commit comments

Comments
 (0)