title: Javascript - Creating an array with FizzBuzz results using a pure recursive function
body: <p>I am trying to get a better understanding of recursion and am thus trying create an array with numbers using the common 'Fizzbuzz' problem. I am trying to do this by implementing a pure recursive function with only one input, but I am having trouble getting my answer to appear in the correct order. I was also curious to know if there was a way to write a pure recursive function that would use push instead of concat in this situation. Any help is appreciated! I am able to print out the desired output, but am doing it in reverse order. Below is what I have so far:</p>
  
  <pre><code> var fizzBuzz = function(n) {
      //create results array
      //create base case for when n === 1
      //recurse and push value to array
      var results = [];
    if (n === 1) {
      return '1';
    } else {
      if (n % 3 === 0 &amp;&amp; n % 5 === 0) {
        results.push('FizzBuzz');
      } else if (n % 5 === 0) {
        results.push('Buzz');
      } else if (n % 3 === 0) {
        results.push('Fizz');
      } else {
        results.push(''+ n);
      }
      return results.concat(fizzBuzz(n - 1));
    }
  };
  </code></pre>