1- const movieLength = 8784 ; // length of movie in seconds
1+ const movieLength = 5 ; // length of movie in seconds
22
33const remainingSeconds = movieLength % 60 ;
44const totalMinutes = ( movieLength - remainingSeconds ) / 60 ;
@@ -12,14 +12,24 @@ 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+ //5
1516
1617// b) How many function calls are there?
18+ //1
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+ //% is the modulo operator, which gives the remainder after operand.
23+ //so in this case, the remainder of movieLength/60,
24+ // the number of seconds not in a whole minute
2025
2126// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
27+ //Take the total number of seconds in the move, minus the remainder of movieLength/60 to give
28+ //a number that divides exactly by 60, then divide that number by 60. it converts the
29+ // time into minutes
2230
2331// e) What do you think the variable result represents? Can you think of a better name for this variable?
32+ //The number of whole minutes in the movie. numFullMinutes
2433
2534// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
35+ //Yes the math is fine and works with all numbers.
0 commit comments