title: Why am I getting undefined instead of null?
body: <p>I wrote a function that returns a day of the week given a number (1 = Monday, 2 = Tuesday etc) and I was supposed to create a caveat where if the number was less than 1 or greater than 7, the function should return null. Why is it instead returning undefined for 0 and 8?</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>daysOfWeek = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
  
  function returnDay(day) {
    day = daysOfWeek[day - 1];
    if (day &gt; 7 || day &lt; 1) {
      return null
    } else {
      return day
    }
  }
  
  console.log(returnDay(8))
  console.log(returnDay(0))</code></pre>
  </div>
  </div>
  </p>