1- const movieLength = 8784 ; // length of movie in seconds
1+ const movieLength = 145678 ; // length of movie in seconds
22
33const remainingSeconds = movieLength % 60 ;
44const totalMinutes = ( movieLength - remainingSeconds ) / 60 ;
@@ -13,13 +13,43 @@ console.log(result);
1313
1414// a) How many variable declarations are there in this program?
1515
16+ // 6
17+
18+
19+
1620// b) How many function calls are there?
1721
22+ // 0
23+
24+
25+
1826// c) Using documentation, explain what the expression movieLength % 60 represents
1927// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
2028
29+ // % is the remainder arithmetic operator. The expression gives the remainder after the number of seconds
30+ // the movie is long is divided by 60. After you have the full amount of minutes this is the amount of
31+ // remaining seconds that don't add up to a full minute.
32+
33+
34+
2135// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
2236
37+ // removing remainingSeconds from movieLength leaves a number of seconds, slightly shorter than the movie length,
38+ // that are an exact amount of minutes. It is divisible by 60. Dividing that number by 60 gives the exact
39+ // number of minutes.
40+
41+
42+
2343// e) What do you think the variable result represents? Can you think of a better name for this variable?
2444
45+ // It represents the movie length as a string expressed in hours, minutes and seconds. A different name could
46+ // be moiveLengthDestructured, movieLengthMessage, movieLengthInHMS, movieLengthFormatted, movieLengthTimeFormat
47+
48+
49+
2550// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
51+
52+ // It technically works for all movie lengths, but the format gets weird. when a value is a single digit, you
53+ // would expect 05 or 00, but it just says 5 or 0 which isn't a standard way to show time. Also, when the
54+ // hours go above 24 you would expect it to start counting days, but the hours just add up instead as
55+ // you try higher values.
0 commit comments