This is my code
const date = new Date(); const startDate = new Date(date.getFullYear(), date.getMonth(), 1); const endDate = new Date(date.getFullYear(), date.getMonth() + 1, 0); const getDateArray = function(start, end) { const arr = []; const dt = new Date(start); while (dt <= end) { arr.push(new Date(dt)); dt.setDate(dt.getDate() + 1); } return arr; } const dateArr = getDateArray(startDate, endDate); in this above code I got the current month date list dateArr, Now I need to group the days by a week, from the week list I need to filter only week start date and weekend date that must be in list formate I tried with the above code but I cant proceed to next.