So I have an array with an x number of dates for example:
const dates= [date1, date2, date3, date4,...]
Where date1, date2, date3, date4 ... are all in Firebase timestamp date format.
So I wanna be able to first convert each date into the day of the week (monday, tuesday...) and I also want to check if one date repeats, so (Monday, Tuesday, Monday, Wednesday, Wednesday)
And if they do repeat id like to get the length of how many times they repeated, and the other ones that don't repeat I also want to get the length of those.
I've tried doing a forEach
like so,
dates.forEach(el=>{
const days = ['Monday', 'Tuesday', 'Wednesday','Thursday', 'Friday', 'Saturday', 'Sunday']
console.log(days[el.toDate().getDay()])
})
But get stuck here, don't really know how to compare if they are the same day. EDIT: I Realized that the date im using is in firebase timestamps
.toDate()exists in vanilla JS.