I am trying to change an array in the following order:
So I have the following array:
const weekDaysArray = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su']; which contains the days of the week in order, then I get a variable
const firstWeekday = Object.values(formattedReadsByDay)[0].dayOfWeek; which will return a day of the week, let's say We for the case.
So when this returns We i would like to change the array to:
weekDaysArray = ['We', 'Th', 'Fr', 'Sa', 'Su', 'Mo', 'Tu'];
I tried weekDaysArray [...weekDays.slice(-1), ...weekDays.slice(0, -1)] this but it doesn't work. Any ideeas?
weekDaysvariable where is defined. Should it beweekDaysArray?[...weekDays.slice(2), ...weekDays.slice(0,2)]