I'm attempting to display the content of the gameTwo
array in two child divs under the game2
element. However, the issue I'm facing is that the loop creates a child of a child on the second iteration. Could someone provide guidance on how I can adjust this code to ensure that both divs are siblings?
var gameTwo = ['Kansas', 'Villanova']
var gameTwoText = '';
for (i = 0; i < gameTwo.length; i++) {
gameTwoText += "<div>" + gameTwo[i];
}
var secondGame = document.getElementById('game2').innerHTML = gameTwoText;