Skip to content

Commit 655acb6

Browse files
committed
Answered questions in 2-time-format.js
1 parent 29409f8 commit 655acb6

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
1-
const movieLength = 8784; // length of movie in seconds
1+
// const movieLength = 8784; // length of movie in seconds
22

3-
const remainingSeconds = movieLength % 60;
4-
const totalMinutes = (movieLength - remainingSeconds) / 60;
3+
// const remainingSeconds = movieLength % 60;
4+
// const totalMinutes = (movieLength - remainingSeconds) / 60;
55

6-
const remainingMinutes = totalMinutes % 60;
7-
const totalHours = (totalMinutes - remainingMinutes) / 60;
6+
// const remainingMinutes = totalMinutes % 60;
7+
// const totalHours = (totalMinutes - remainingMinutes) / 60;
88

9-
const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`;
10-
console.log(result);
9+
// const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`;
10+
// console.log(result);
1111

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, lines 1,3,4,6,7,9
1516

1617
// b) How many function calls are there?
18+
//1 at line 10
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+
//This is using a remainder, this us seeing how many times 8784 goes into 60 and what is remaining which is 24 in this case:
23+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Remainder
2024

2125
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
26+
// It is the sum of movieLength minus remainingSeconds then divided by 60
2227

2328
// e) What do you think the variable result represents? Can you think of a better name for this variable?
29+
// its showing the length of the movie in hours, minutes and seconds, could be better called something like MovieDuration
2430

2531
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
32+
//Yes it will as long as the input is numerical numbers only, it does not work with any extra symbols, spaces or letters.

0 commit comments

Comments
 (0)