Skip to content

Commit ceb48a4

Browse files
committed
complete 2-time-format.js ex.
1 parent 26b2e4d commit ceb48a4

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎Sprint-2/3-mandatory-interpret/2-time-format.js‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff 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 in total: movieLength, remainingSeconds, totalMinutes,
16+
remainingMinutes, totalHours, and result.*/
1517

1618
// b) How many function calls are there?
19+
// -There is one function call: console.log(result);
1720

1821
// c) Using documentation, explain what the expression movieLength % 60 represents
1922
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
23+
/* -The expression movieLength %60 means find the reminder after dividing by 60.
24+
It represents the number of seconds left over after all the full minutes have been removed. */
2025

2126
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
27+
/* -The expression assigned to totalMinutes removes the leftover seconds and then divides
28+
the remaining total seconds by 60. This gives the total number of whole minutes.*/
2229

2330
// e) What do you think the variable result represents? Can you think of a better name for this variable?
31+
/* -The variable result represents the movie length as a readable time string in the format hours:minutes:seconds.
32+
A better name could be formattedTime or timeString.*/
2433

2534
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
35+
/* -This code works for normal values of movieLength that are non-negative whole numbers of seconds.
36+
it does not work for negative values and decimal values.*/

0 commit comments

Comments
 (0)