title: Recursive function to determine if number is even or odd by subtracting two from n until n = 0 or 1
body: <p>Zero is even.</p>
  
  <p>One is odd.</p>
  
  <p>For any other number N, its evenness is the same as N - 2.</p>
  
  <p>Define a recursive function isEven corresponding to this description. The function should accept a single parameter (a positive, whole number) and return a Boolean.</p>
  
  <p>Here is my implementation of isEven:</p>
  
  <pre><code>let isEven = function(n){
      even = 0;
      odd = 1;
      if(n == even){
        return true;
      }
      else if (n == odd) {
        return false;
      }
      else{
        n -= 2;
        console.log(n); //Used to see value of n through each call
        isEven(n);
      }
    };
  </code></pre>
  
  <p>When I call this function, it returns <code>undefined</code></p>
  
  <pre><code>  document.write(isEven(50)); //prints `undefined`
  </code></pre>
  
  <p>The output from <code>console.log(n)</code> is the following: </p>
  
  <pre><code>Failed to load resource: net::ERR_FILE_NOT_FOUND
  48
  46
  ...
  0
  </code></pre>
  
  <p>I am not sure why <code>Failed to load resource: net::ERR_FILE_NOT_FOUND</code> is the first output, but after that <code>n</code> is hitting <code>0</code>, so why is </p>
  
  <pre><code>if(n == even){
            return true;
          }?  
  </code></pre>
  
  <p>not executing? </p>