title: Uncaught TypeError: undefined is not a function
body: <p>Hi everyone I'm currently a student working on a project out of my book, here is the code I am having the issue with.</p>
  <pre><code>for (var i = 0; i &lt; numAsteroids; i++) {
      var radius = 5+(Math.random()*10);
      var x = canvasWidth+radius+Math.floor(Math.random()*canvasWidth);
      var y = Math.floor(Math.random()*canvasHeight);
      var vX = -5-(Math.random()*5);
      
      asteroids.push(new Asteroid(x, y, radius, vX));***&lt;---line 21***
  };
  </code></pre>
  <p>Now when I run this is keeps telling me I have an:</p>
  <blockquote>
  <p>Uncaught TypeError: undefined is not a function line 21.</p>
  </blockquote>
  <p>But I have the code exactly how it is in my book that's what I don't understand. If anyone could help me with this problem it would be great!</p>