I have an array of strings in this format: "2023-01-30"
. The dates range from past, to present, to future. I want to sort the dates into separate arrays based on the work weeks (monday through friday) that they fall into with past weeks falling into the present week.
For instance, given the array ["2022-02-15", 2023-01-30", "2023-02-03", "2023-02-06", "2023-02-14"]
I want to sort into a 2d array with the first array being this week and all past events, and following arrays being subsequent weeks: [["2022-02-15", 2023-01-30", "2023-02-03"], ["2023-02-06"], ["2023-02-14"]]
. I'm trying to use the js Date()
object to accomplish this but something in my logic is off. Thanks in advance!