File tree Expand file tree Collapse file tree
Sprint-2/3-mandatory-interpret Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -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+ // There are 6 variable declarations.
1516
1617// b) How many function calls are there?
18+ // There is 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+ // % is the remainder operator. It returns what is left over after dividing one number by another.
24+ // movieLength % 60 gives the seconds left over once all the full minutes are taken out of the movie length.
25+ // 8784 % 60 = 24, because 8784 seconds is 146 full minutes with 24 seconds left over.
26+
2127// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
28+ // It subtracts the leftover seconds from the movie length, leaving a number that divides evenly by 60
29+ // (8784 - 24 = 8760), then divides by 60 to get the number of whole minutes (8760 / 60 = 146).
30+ // So totalMinutes is the total number of complete minutes in the movie.
2231
2332// e) What do you think the variable result represents? Can you think of a better name for this variable?
33+ // The variable result represents the total length of the movie in hours, minutes and seconds. A better name would be movieLengthHHMMSS.
2434
2535// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
36+
You can’t perform that action at this time.
0 commit comments