Home>

So, I have this construction:

const PC_Card_Hand= document.querySelector('.comp-card-hand1');
PC_Card_Hand.appendChild(DECK_PC[0].getHTML());

It reads the first value from the arrayDECK_PCand then creates the elementDIVwith classcardwith data from array in elementdivwith classcomp-card-hand1and everything works great. There are just two problems:

  1. I have more than one element in the array
  2. Elementsdivwith classcomp-card-hand1also more than one

And all attempts to somehow loop this process and force elements from the array to be placed in freedivs do not lead to anything good and all the data is stubbornly stuffed into the very first element founddivwith classcomp-card-hand1

So the question is: how can I solve this problem and force the data from the array to be written to different (free)divwith classcomp-card-hand1?

CLARIFICATION: the array contains 50 elements, and the elementsdivwith classcomp-card-hand13 pieces. I want the first 3 values ​​of the DECK_PC array to be inserted into these divs. And if one of them is released, then the next element in turn should be inserted there.