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,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+ // Answer: There are 6 variable declarations.
1516
1617// b) How many function calls are there?
18+ // Answer: There is 1 function call: console.log(result).
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+ // Answer: movieLength % 60 gives the remainder after dividing movieLength by 60.
23+ // This represents the remaining seconds after converting the time into whole minutes.
2024
2125// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
26+ // Answer: It subtracts the remaining seconds from movieLength and divides by 60.
27+ // This gives the total number of whole minutes in the movie.
2228
2329// e) What do you think the variable result represents? Can you think of a better name for this variable?
30+ // Answer: result represents the movie length formatted as hours, minutes and seconds.
31+ // A better variable name would be formattedMovieLength.
2432
2533// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
34+ // Answer: No, it will not format all values correctly.
35+ // For example, single-digit minutes or seconds will not have a leading zero.
You can’t perform that action at this time.
0 commit comments