Skip to content
Advertisement

Take time values into integer? [closed]

I have an object that looks like this:

JavaScript

I want to simply take these values and parse them into a integer between 0-24 basically, currently I’m taking it in like this:

JavaScript

Is there a better way to do this?

Advertisement

Answer

This solution maps the time format input to a number between 0 (inclusive) to 24 (exclusive), just like the 24-hours format.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement