title: Khan academy, towers of hanoi recursion
body: <p>Challenge Solve hanoi recursively</p>
  
  <p>I cannot get past stage 2 of this challenge, which is a shame as it means I can't coimplete anything.  Can anyone help?</p>
  
  <p>The link is here:
  <a href="https://www.khanacademy.org/computing/computer-science/algorithms/towers-of-hanoi/p/challenge-solve-hanoi-recursively" rel="nofollow noreferrer">https://www.khanacademy.org/computing/computer-science/algorithms/towers-of-hanoi/p/challenge-solve-hanoi-recursively</a></p>
  
  <p><strong>The questions asks the following:</strong></p>
  
  <p>Make a recursive function call to move the disks sitting on top of the bottom disk on the fromPeg to the spare peg, i.e. move (numDisks - 1) disks to the spare peg.</p>
  
  <p>You can find the spare peg by using the getSparePeg function.</p>
  
  <p>A call to hanoi.getSparePeg(peg1,peg2) returns the remaining peg that isn't peg1 or peg2.</p>
  
  <p><strong>The hint says this:</strong></p>
  
  <p>// recursive case:</p>
  
  <pre><code>var sparePeg = hanoi.getSparePeg(fromPeg, toPeg);
  solveHanoi();
  </code></pre>
  
  <p>But despite all that, even though it only seems to ask for the solveHanoi() to be filled out with the parameters, it wont progress. Do I have to seperately declare the fromPeg, and toPeg, and assign them letters? </p>
  
  <p><strong>Below is a rough stab at the code:</strong></p>
  
  <pre><code>var solveHanoi = function(numDisks, fromPeg, toPeg) {
      if (numDisks===0)
      {
         return;
      }
  };    
  var fromPeg="A";
  var toPeg="B";
  var sparePeg = hanoi.getSparePeg(fromPeg,toPeg);
  //solveHanoi(5, "A","B");
  //Program.assertEqual(hanoi.isSolved("B"),true);
  </code></pre>