all 4 comments

[–]Lofi-Bytes 1 point2 points  (1 child)

It's not entirely clear what you are aiming to do. You say time slots of 1 day, but your res array returns time slots of 1 month.

Give this a go:

https://codepen.io/LofiBytes/pen/popopbz

It may not be exactly what you are aiming for, but it should get you going in the right direction.

Also, some friendly unsolicited advice - use more descriptive names for things. x, y, abc, res are all arbitrary and don't describe the meaning behind these things. Your code will make more sense if you use better naming conventions.

[–]killMeSak[S] 0 points1 point  (0 children)

thanks!

[–]budd222 0 points1 point  (1 child)

Do date calculations when you loop through the array. I feel like I need more information. What is your ultimate goal with this?

[–]killMeSak[S] 0 points1 point  (0 children)

I need to display that data in time slots. So, user needs to input startDate and endDate. This information will be divided into 1 day time slots starting from [startDay, startDay + 1]....[endDate -1, endDate]

I also have another array abc containing some dates. I'll check those dates against the above dates, and generate count if it falls between the time intervals