title: Recursive array with a push
body: <p>Can someone show me where I am going wrong within this Code Academy problem.  I'm having a world of trouble with Recursion and am only vaguely beginning to understand how it works at a fundamental level... The first set of code is what I have written followed by the same code with the blanks I have tried to fill in.</p>
  
  <blockquote>
    <p><strong>Fill in the blanks:</strong> Write a conditional statement for the base case of <code>multiplyEach()</code>. We want to end the recursion when there are no more values in stack. Then we want to return the variable <code>int</code>, since this represents the last value evaluated. Complete the recursive case with a recursive call to the function, without any arguments.</p>
  </blockquote>
  
  <p><strong>Blank Problem with fill-in-the-blanks</strong> <em>(</em><code>___</code><em>)</em>:</p>
  
  <pre><code>var stack = [];
  
  function countDown(int) {
    stack.push(int);
    if (int === 1) {  
      return 1;
    }
      return countDown(int - 1);
  }
  
  function multiplyEach() {
    // Remove the last value of the stack 
    // and assign it to the variable int
    int = stack.pop();
    x = stack.length;
    // Base case
    if (___) {
      return ___;
    }
    // Recursive case
    else {
      stack[x - 1] = int * stack[x - 1];
      return ___;
    }
  }
  
  // Call the function countDown(7)
  countDown(7);
  // And then print out the value returned by multiplyEach()
  console.log(multiplyEach());
  </code></pre>
  
  <p><strong>This is my Try:</strong></p>
  
  <pre><code>var stack = [];
  
  function countDown(int) {
    stack.push(int);
    if (int === 1) {  
      return 1;
    }
      return countDown(int - 1);
  }
  
  function multiplyEach() {
    // Remove the last value of the stack 
    // and assign it to the variable int
    int = stack.pop(int);
    x = stack.length;
    // Base case
    if (x === 0) {
      return int;
    }
    // Recursive case
    else {
      stack[x - 1] = int * stack[x - 1];
      return multiplyEach(stack);
    }
  }
  
  // Call the function countDown(7)
  countDown(7);
  // And then print out the value returned by multiplyEach()
  console.log(multiplyEach());
  </code></pre>
  
  <p>Thanks!</p>