1- const movieLength = 8784 ; // length of movie in seconds
1+ const movieLength = 8788 ; // length of movie in seconds
22
33const remainingSeconds = movieLength % 60 ;
44const totalMinutes = ( movieLength - remainingSeconds ) / 60 ;
@@ -12,14 +12,25 @@ 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+ // a) 6 variable declarations
1516
1617// b) How many function calls are there?
18+ // b) 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
2022
23+ // c) % gives the remainder after division.
24+ // movieLength % 60 finds the remaining seconds after dividing the movie length by 60.
25+
2126// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
27+ // d) totalMinutes is assigned the value 146 after subtracting the remaining seconds
28+ // from movieLength and dividing the result by 60
2229
2330// e) What do you think the variable result represents? Can you think of a better name for this variable?
31+ // e) It creates the movie's time format
32+ // Maybe a more descriptive movieTime or movieDuration
2433
2534// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
35+ // f) The code works for different whole-number values of movieLength
36+ // the result changes depending on the movie's length
0 commit comments