'How to generate images dynamically from JS and display them onload?

I want to images from an array and upon onload of the browser window it gets display on the webpage. this is what I did.

const players = [
    {
     photo: 'img/photo0.jpeg'
    },
    {
     photo: 'img/photo1.jpeg'
    },
    {
     photo: 'img/photo2.jpeg'
    }]

// This is the function I built to do that.
    function() {

      for(i = 0; i < players.lengh; i++;){
      }
    }


Solution 1:[1]

You could access to the onLoad method through the window object.

window.onload = function() {
  // Whatever you want to do on load
};

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jesus CastaƱeda