title: Rewriting for loop with forEach
body: <p>I want to rewrite the following code:</p>
  
  <pre><code>    for(i = 0; i &lt; grounds.length; i++) {
          grounds[i].show();
      }
  </code></pre>
  
  <p>with a forEach method in a way:</p>
  
  <pre><code>grounds.forEach(**what should i post here?**);
  </code></pre>
  
  <p>Full code:</p>
  
  <pre><code> class Ground {
          constructor(x, y, sizeX, sizeY) {
              this.x = x;
              this.y = y;
              this.sizeX = sizeX;
              this.sizeY = sizeY;
          }
  
          show() {
              ctx.fillStyle = "rgb(138, 75, 13)";
              ctx.fillRect(this.x, this.y, this.sizeX, this.sizeY);
          }
      }
  }
  
  
  let ground;
  let grounds = [];
  
  function generateGround() {
      for(i = 0; i &lt; 10; i++) {
          ground = new Ground(0 + i * 40, canvas.height - 30, 40, 30);
          grounds.push(ground);
      }
  }
  
  generateGround();
  
  function draw() {
  
      for(i = 0; i &lt; grounds.length; i++) {
          grounds[i].show();
      }
  
      requestAnimationFrame(draw);
  }
  requestAnimationFrame(draw);
  </code></pre>
  
  <p>I read few examples, but i can't find a way to execute show() method for each ground element.</p>