File tree Expand file tree Collapse file tree
Sprint-1/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+ let movieLength = 8784 ; // length of movie in seconds
2+ movieLength = 9000 ;
3+ movieLength = 6500 ;
24
35const remainingSeconds = movieLength % 60 ;
46const totalMinutes = ( movieLength - remainingSeconds ) / 60 ;
@@ -11,15 +13,23 @@ console.log(result);
1113
1214// For the piece of code above, read the code and then answer the following questions
1315
16+
1417// a) How many variable declarations are there in this program?
18+ // there is 6 variable declaration
1519
1620// b) How many function calls are there?
21+ // there is only the log() call
1722
1823// c) Using documentation, explain what the expression movieLength % 60 represents
1924// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
25+ // the logic is to calculate the movieLength remainder - operator returns the remainder left over when one operand is divided by a second operand.
26+ // It always takes the sign of the dividend.
2027
2128// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
29+ // to calculate the movie length 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 result represent the movie length - hours minutes and second in a string - movieTime
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 above logic calculates the movie length in hours minutes and seconds
You can’t perform that action at this time.
0 commit comments