Question: I have the following games object:

```
window.games ={
    "game1": {
        name: "game1", 
        url: "", 
    },
    "game2": {
        name: "game2", 
        url: "", 
    },
    "game3": {
        name: "game3", 
        url: "", 
    },
    "game4": {
        name: "game4", 
        url: "", 
    },
};

```

and the following selected games array

```
window.selectedGames = ["game2", "game3"];

```

I am using a forEach to take each game from the selected games array and using the data from the object to render an html element:

```
 selectedGames.forEach(game => {
        for (var [key, value] of Object.entries(games)) {
            if (key === game) {
                var jackpotContainer = document.querySelector(".sub-jackpot-container");
                gameContainer = document.createElement('div');
                jackpotContainer.appendChild(gameContainer);
                gameBox = document.createElement('div');
                link = document.createElement('a');
                link.href = value.url;
                gameContainer.appendChild(gameBox);
                gameContainer.appendChild(link);
                gameName = document.createElement('span');
                gameName.classList = 'game-name';
                gameName.innerHTML = value.name;
            }
        }
    });

```

I cannot figure out how can I change this forEach into a for loop so this can be supported on IE as well. I'll be very thankful for any help.

Answer: 
```
selectedGames.forEach(game => {
    // ...
});

```

would become:

```
for (var i=0; i < selectedGames.length; i++) {
    var game = selectedGames[i];
    // ....
}

```
Looking at your loop I think its better to loop through the elements you want rather than looping through everything and checking if it matches or not. 

Something like this: 

```js
window.games ={
    "game1": {
        name: "game1", 
        url: "", 
    },
    "game2": {
        name: "game2", 
        url: "", 
    },
    "game3": {
        name: "game3", 
        url: "", 
    },
    "game4": {
        name: "game4", 
        url: "", 
    },
};

window.selectedGames = ["game2", "game3"];

window.selectedGames.forEach(selected_game => {
  game = window.games[selected_game];

  if (game !== undefined) {
    // You can do whatever you want here
    console.log(game.name);
    console.log(game.url);
  }

 });
```