Skip to content

Commit e109be6

Browse files
Completed mandatory interpret excercise 2
1 parent 44be7d7 commit e109be6

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,28 @@ 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 - movieLength
16+
remainingSeconds
17+
totalMinutes
18+
remainingMinutes
19+
totalHours
20+
result */
1521

1622
// b) How many function calls are there?
23+
// 1, console.log() is the only function call in this program
1724

1825
// c) Using documentation, explain what the expression movieLength % 60 represents
1926
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
27+
// % returns the remainder.
2028

2129
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
30+
// The expression assigned to totalMinutes is calculating the total number of minutes in the movie length
31+
// by subtracting the remaining seconds from the total movie length and then dividing that value by 60.
32+
// This gives us the total number of whole minutes in the movie length.
2233

2334
// e) What do you think the variable result represents? Can you think of a better name for this variable?
35+
// The variable result represents the total length of the movie in hours, minutes, and seconds.
36+
// A better name for this variable could be "movieDuration".
2437

2538
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
39+
// The code works for non-negative whole numbers. Negative or decimal values may produce incorrect or unexpected results.

0 commit comments

Comments
 (0)