Skip to content

Commit 9080a92

Browse files
committed
completed the exercises
1 parent 3231276 commit 9080a92

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
const movieLength = 8784; // length of movie in seconds
1+
let movieLength = 8784; // length of movie in seconds
2+
movieLength = 9000;
3+
movieLength = 6500;
24

35
const remainingSeconds = movieLength % 60;
46
const totalMinutes = (movieLength - remainingSeconds) / 60;
@@ -11,15 +13,23 @@ console.log(result);
1113

1214
// For the piece of code above, read the code and then answer the following questions
1315

16+
1417
// a) How many variable declarations are there in this program?
18+
// there is 6 variable declaration
1519

1620
// b) How many function calls are there?
21+
// there is only the log() call
1722

1823
// c) Using documentation, explain what the expression movieLength % 60 represents
1924
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
25+
// the logic is to calculate the movieLength remainder - operator returns the remainder left over when one operand is divided by a second operand.
26+
// It always takes the sign of the dividend.
2027

2128
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
29+
// to calculate the movie length into minutes
2230

2331
// e) What do you think the variable result represents? Can you think of a better name for this variable?
32+
// the result represent the movie length - hours minutes and second in a string - movieTime
2433

2534
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
35+
// Yes - the above logic calculates the movie length in hours minutes and seconds

0 commit comments

Comments
 (0)