title: Range using recursion, how to output a new array Javascript
body: <p>How do you output a new array using recursion without declaring an empty array outside of the function? Another way of doing it will be creating an inner function and then <code>return newFunction()</code>, but it is not allowed as the task is to call the function itself. Here's what I have so far:</p>
  
  <pre><code>var newArr=[];
  var range = function(x, y) {
      if(x === y-1){
          return newArr;
      }
      if(x &lt; y){
          newArr.push(x+1);
          newArr = range(x+1,y);
      }
      else{
          newArr.push(x-1);
          newArr = range(x-1,y);
      }
      return newArr;
  };
  range(2,10) //[3,4,5,6,7,8,9]
  </code></pre>