Skip to content

Commit 7fcde6c

Browse files
committed
interpret exercise 2
1 parent 1ca36f7 commit 7fcde6c

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

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

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

33
const remainingSeconds = movieLength % 60;
44
const totalMinutes = (movieLength - remainingSeconds) / 60;
@@ -12,14 +12,20 @@ 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
1516

1617
// b) How many function calls are there?
18+
// none
1719

1820
// c) Using documentation, explain what the expression movieLength % 60 represents
21+
// movieLength represents the total seconds and with the remainder operator it represents the amount of seconds left over after the number is divided by 60
1922
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
2023

2124
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
25+
// It means to create the amount of total minutes by subtracting the remainingSeconds from movieLength and dividing the resulting number of seconds by 60 to get the result in minutes
2226

2327
// e) What do you think the variable result represents? Can you think of a better name for this variable?
28+
// It represents the movie length in hours, minutes and seconds. A better name would be totalMovielength
2429

2530
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
31+
// I changed the movieLength to 18784 and the code still works as it gave me back 5:13:4 after running it. The variables would need to be altered or changed for it to stop working.

0 commit comments

Comments
 (0)