title: How to call class function in JavaScript?
body: <p>New to JavaScript so might be something simple.</p>
  
  <p><strong>Getting an Error:</strong></p>
  
  <blockquote>
    <p>ball.html:46 Uncaught SyntaxError: Unexpected identifier</p>
  </blockquote>
  
  <p>Why this is happening? I am new to JavaScript. But I tried everything in my knowledge to fix it. Tried removing the <code>function</code> but then it gives error:</p>
  
  <blockquote>
    <p>draw() function is not defined in repeatMe() function.</p>
  </blockquote>
  
  <p><strong>HTML and JavaScript:</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
  
    &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;Canvas&lt;/title&gt;
  
      &lt;style type="text/css"&gt;
        body {
            background-color: white;
        }
  
        canvas { 
          border: 3px solid black; 
      }
      &lt;/style&gt;
  
    &lt;/head&gt;
  
    &lt;body&gt;
  
      &lt;canvas id="canvas-for-ball" height="800px" width="800px"&gt;&lt;/canvas&gt;
  
      &lt;script type="text/javascript"&gt;
        // Gets a handle to the element with id canvasOne.
        var canvas = document.getElementById("canvas-for-ball");
        // Get a 2D context for the canvas.
        var ctx = canvas.getContext("2d");
  
        // The vertical location of the ball.
        var y = 10;
        var x = 10;
        var ballRadius = 3;
        var ySpeed = 1;
  
        class Ball {
          constructor(x, y, ballRadius, ySpeed) {
              this.x = x;
              this.y = y
              this.ballRadius = BallRadius;
              this.ySpeed = ySpeed;
          }//endConstructor
  
          function drawball() {
              ctx.beginPath();
              ctx.arc(x, y, ballRadius, 0, 2 * Math.PI);
              ctx.stroke();
          }//endDrawball
  
          function draw() {
              ctx.clearRect(1, 1, 800, 800);
              drawball(); 
          }//endDraw
  
          function move() {
              // Update the y location.
              y += ySpeed;
              console.log(y);
          }
        } //endBall
  
  
        // A function to repeat every time the animation loops.
        function repeatme() {
          // Draw the ball (stroked, not filled).
          draw();
          move();
  
          //catch ball at bottom
          if (y == 800)
          {
               ySpeed = 0;
          }
  
          window.requestAnimationFrame(repeatme);
        }
  
        // Get the animation going.
        repeatme();
      &lt;/script&gt;
  
    &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>