Skip to content

Commit 784ff5d

Browse files
committed
tested the code and answered the questions
1 parent 88837ec commit 784ff5d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

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

Lines changed: 9 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 = 7784; // length of movie in seconds
22

33
const remainingSeconds = movieLength % 60;
44
const totalMinutes = (movieLength - remainingSeconds) / 60;
@@ -12,14 +12,22 @@ 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 this program. They are on lines 1, 3, 4, 6, 7 and 9
1516

1617
// b) How many function calls are there?
18+
// there are 2 function calls in this program. They are on lines 9 and 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+
// the expression movieLength % 60 is using the modulus operator (%) to find the remainder when movieLength (8784) is divided by 60.
2023

2124
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
25+
/* line 4 is calculating the total number of minutes in the movie by subtracting the remaining seconds from the total movie length in
26+
seconds and then dividing that result by 60.*/
2227

2328
// e) What do you think the variable result represents? Can you think of a better name for this variable?
29+
/* the variable result represents the total length of the movie in hours, minutes and seconds. A better name for this variable could
30+
be movieDuration.*/
2431

2532
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
33+
// yes this code will work for all values of movieLength as long as the value is a non-negative integer representing the length of a movie in seconds.

0 commit comments

Comments
 (0)