Skip to content

Commit bae8454

Browse files
committed
answered all questions in 2-time-format.js
1 parent d8e5852 commit bae8454

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const movieLength = 8784; // length of movie in seconds
1+
// const movieLength = 8784; // length of movie in seconds
2+
const movieLength = 879094; // length of movie in seconds
23

34
const remainingSeconds = movieLength % 60;
45
const totalMinutes = (movieLength - remainingSeconds) / 60;
@@ -12,14 +13,24 @@ console.log(result);
1213
// For the piece of code above, read the code and then answer the following questions
1314

1415
// a) How many variable declarations are there in this program?
16+
// 6
1517

1618
// b) How many function calls are there?
19+
// 1
1720

1821
// c) Using documentation, explain what the expression movieLength % 60 represents
1922
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
23+
// % is the modulos operator, movieLength % 60 gives us the remainder, essentially we divide 60 by movieLenght and return the remainder
2024

2125
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
26+
/* we are subtracting remainingSeconds from movieLength, remainingSeconds is a variable that holds the result from totalMinutes % 60,
27+
the expression in brackets will evaluate first and then the result divided by 60.
28+
*/
2229

2330
// e) What do you think the variable result represents? Can you think of a better name for this variable?
24-
31+
//runTime
2532
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
33+
/* I have experimented with different values by changing the movieLength variable, and they all work, it works because we have
34+
didn't hardcode our expressions and used variables.
35+
*/
36+

0 commit comments

Comments
 (0)