Skip to content

Commit c09b8c7

Browse files
committed
Solution: mandatory-interpret, 2-time-format
1 parent 6ddb568 commit c09b8c7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Sprint-1/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 = -9.5; // 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+
// Answer: 6 in total (on lines 1, 3, 4, 6, and 7)
1516

1617
// b) How many function calls are there?
18+
// Answer: 3 (on 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+
// Answer: It returns the modulus (i.e. remainder) of a division
2023

2124
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
25+
// Answer: It's the floor of the movie runtime in minutes
2226

2327
// e) What do you think the variable result represents? Can you think of a better name for this variable?
28+
// Answer: it's the formatted runtime of the movie (in Hours:Minutes:Seconds). A better name could be formattedRuntime
2429

2530
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
31+
// Answer: It won't work for all values, for example strings

0 commit comments

Comments
 (0)