title: Calling a function within a loop, "Undefined is not a function"
body: <p>I have two functions at the top of my code. Below in a <code>while (i&lt;1)</code> loop, I call one of the functions above. This works the first time, but the second time the function is called it displays an error: </p>
  
  <blockquote>
    <p>TypeError: undefined is not a function</p>
  </blockquote>
  
  <p>Below is the code:</p>
  
  <pre><code>var i = 0;
  var newBalance = 0;
  var deposit = function(amountIn)
  {
      newBalance = (newBalance + amountIn).toFixed(2);
  };
  var withdrawl = function(amountOut)
  {
      newBalance = (newBalance - amountOut).toFixed(2);
  };
  var choice = prompt("Would you like to access your account?").toLowerCase();
  if (choice === "yes"){
      while (i&lt;1){
  
          var inOrOut = prompt("Are you making a deposit or a withdrawl?").toLowerCase();
          var strAmount = prompt("How much money are you trasfering?");
          var amount = parseFloat(strAmount);
  
          if (inOrOut === "deposit")
          {
              deposit(amount);
          }
          else if (inOrOut === "withdrawl")
          {
              withdrawl(amount);
          }
          else
          {
              console.log("You did not enter a valid number");
          }
  
          console.log("Your new balance is $" + newBalance);
          var choiceTwo = prompt("Would you like to make another transaction?").toLowerCase();
          if (choiceTwo === "no")
          {
              i = i + 1;
          }
      }
  }
  </code></pre>