title: How to move array with days of week one item backwards js
body: <p>I have two arrays</p>
  <pre><code>const weekDays = [
    { label: 'Mon', name: 'Monday' },
    { label: 'Tue', name: 'Tuesday' },
    { label: 'Wed', name: 'Wednesday' },
    { label: 'Thu', name: 'Thursday' },
    { label: 'Fri', name: 'Friday' },
    { label: 'Sat', name: 'Saturday' },
    { label: 'Sun', name: 'Sunday' },
  ];
  </code></pre>
  <p>and <code>const daysOfWeek = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri']</code></p>
  <p>What I wanted to achieve is to move array(daysOfWeek) one item backwards, that is, <code>daysOfWeek = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu']</code>.</p>
  <p>To achieve that I created such code</p>
  <pre><code>const selectedDaysOfWeek = weekDays.map(({label, name}, index, array) =&gt; {
     if (daysOfWeek.includes(label)) {
         return array[index - 1].label;
     }
     return ''
  });
  </code></pre>
  <p>but it returns label of undefined.</p>