Skip to content

Commit f0f1ed3

Browse files
authored
Create 1904-the-number-of-full-rounds-you-have-played.js
1 parent 444ada3 commit f0f1ed3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @param {string} startTime
3+
* @param {string} finishTime
4+
* @return {number}
5+
*/
6+
const numberOfRounds = function(startTime, finishTime) {
7+
let start = 60 * parseInt(startTime.slice(0, 2)) + parseInt(startTime.slice(3))
8+
let finish = 60 * parseInt(finishTime.slice(0, 2)) + parseInt(finishTime.slice(3));
9+
if (start > finish) finish += 60 * 24; // If `finishTime` is earlier than `startTime`, add 24 hours to `finishTime`.
10+
return Math.floor(finish / 15) - Math.ceil(start / 15); // floor(finish / 15) - ceil(start / 15)
11+
};

0 commit comments

Comments
 (0)