I have 3 HTML columns and an array with 3 objects within it. I'm trying to loop through the array and append the value within the array to each of the HTML column. So the first object in the array to the first column ,second object to the second column. Which type of loop would be best for this scenario?
var shortenedCast = fullCast.slice(0, 3);
var arrayLength = shortenedCast.length; //3
var columns = document.getElementsByClassName("panel-item");
var characterP = document.getElementsByClassName("character");
for (var i = 0; i < arrayLength; i++) {
console.log(shortenedCast[i].character);
//John wick
//Viggo Tarasov
//Iosef Tarasov
characterP.textContent = shortenedCast[i].character;
}
console.log(shortenedCast);
<div class="column small-4">
<div class="panel-item">
<p class="character"></p>
</div>
</div>
<div class="column small-4">
<div class="panel-item">
<p class="character"></p>
</div>
</div>
<div class="column small-4">
<div class="panel-item">
<p class="character"></p>
</div>
</div>