Skip to content

Commit 7d1a29e

Browse files
committed
interpreted the program in 2-time-formation.js file
1 parent a5691d2 commit 7d1a29e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,25 @@ 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+
// 6
1516

1617
// b) How many function calls are there?
18+
// 1
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+
//Remainder operator.
23+
//The remainder (%) operator returns the remainder left over when one operand is divided by a second operand.
24+
// It always takes the sign of the dividend.
2025

2126
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
27+
// The value stored in totalMinute is calculating the number of minutes that have elapsed in the movie by subtracting the remaining time from the total duration and converting seconds to minutes.
2228

2329
// e) What do you think the variable result represents? Can you think of a better name for this variable?
30+
//The variable result represents a formatted time string in the format HH:MM:SS.
31+
// A better name would be "movieDurationDisplay", as these names more clearly describe the purpose and content of the variable.
2432

2533
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
34+
// No. Not for all possible values of movieLength, some EdgeCases are:
35+
//1. when movieLength is of negative value, the maths produces negative time and its illogical for a movie duration
36+
//2. if movieLength is not a number, its produces "NAN" and this breaks mathematically

0 commit comments

Comments
 (0)