Skip to content

Commit cce5a1c

Browse files
committed
completed tasks in Sprint-1/2-mandatory-interpret/2-time-format.js
1 parent c172453 commit cce5a1c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,25 @@ console.log(result);
1313

1414
// a) How many variable declarations are there in this program?
1515

16+
// There are 6 variable declaration, they are: movieLength, remainingSeconds, totalMinutes, remainingMinutes, totalHours, result
17+
1618
// b) How many function calls are there?
1719

20+
//There is only one function call, the console.log() in line 10
21+
1822
// c) Using documentation, explain what the expression movieLength % 60 represents
1923
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
2024

25+
//movieLength % 60 is the remainder of the division of movieLength by 60 i.e it provides the remaining seconds when movieLength is converted to minutes through the use of the modulus operator % that returns the remainder of a division
26+
2127
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
2228

29+
// totalMinutes is the total number of full minutes in the movie length , calculated by first removing the remaining seconds then dividing by 60 to convert to minutes
30+
2331
// e) What do you think the variable result represents? Can you think of a better name for this variable?
2432

33+
// result represents the movie length in hours:minutes:seconds format. It would be better to name it formattedMovieLength or movieLengthHMS
34+
2535
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
36+
37+
// Yes the code will work for all values of movieLength, because the use of a variable makes it so that the code can be reused for any value of movieLength

0 commit comments

Comments
 (0)