Skip to content

Commit 4072533

Browse files
committed
run the code and edit my answers
1 parent c52de96 commit 4072533

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

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

33
const remainingSeconds = movieLength % 60;
44
const totalMinutes = (movieLength - remainingSeconds) / 60;
@@ -9,17 +9,21 @@ const totalHours = (totalMinutes - remainingMinutes) / 60;
99
const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`;
1010
console.log(result);
1111

12-
// For the piece of code above, read the code and then answer the following questions
1312

14-
// a) How many variable declarations are there in this program?
1513

16-
// b) How many function calls are there?
1714

18-
// c) Using documentation, explain what the expression movieLength % 60 represents
19-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
15+
//A.There are six variable declararions
2016

21-
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
17+
//B. no function calls
2218

23-
// e) What do you think the variable result represents? Can you think of a better name for this variable?
19+
// C.The % represents a remainder. The operator returns the remainder leftover when one operand which in
20+
// this cas is movieLength is divided by a second operand in this case 60%.
2421

22+
23+
// D.it means it is changing the value that was in second into minute by dividing it 60 after the top calculation makes it whole number.
24+
25+
//E. It represents the duration of the movie.movieLength/movieDuration.
26+
2527
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
28+
29+
// yes it works, i experimented it with various values. I found it to be working properly.

0 commit comments

Comments
 (0)