Javascript get days of week range numbers array, between two numbers, conforming to ISOWeekday

Viewed 113

So I'm trying to get an array of day numbers, in a specific range, conforming to ISOWeekday (returns 1-7 where 1 is Monday and 7 is Sunday)

So if a work week starts at Sunday (7) and ends on Thuesday (4),

I need to output this array: 7,1,2,3,4

const startWeek = 7;
const endWeek = 4;
for (let i = 1; i < 7; i++) {
  if (i > startWeek && i < endWeek) {
    console.log(i);
  }
}

2 Answers
Related