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 1- const movieLength = 8784 ; // length of movie in seconds
1+ const movieLength = 2 ; // length of movie in seconds
22
33const remainingSeconds = movieLength % 60 ;
44const totalMinutes = ( movieLength - remainingSeconds ) / 60 ;
@@ -12,14 +12,21 @@ 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+ // 6
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+ // its a rem calculation, basically taking how many groups of 60 are in the movie, the remaining sec is the result.
2023
2124// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
25+ // (movieLength - remainingSeconds): will give us a whole number
26+ // / 60: takes the whole number and converts it to minutes
2227
2328// e) What do you think the variable result represents? Can you think of a better name for this variable?
29+ // the movie length in hours, minutes and seconds
2430
2531// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
32+ // edge case: negative movie length. For negative movie lengths it should print an error saying that movielength cannot be less than 0.
You can’t perform that action at this time.
0 commit comments