I want to add 3 elements to each empty array preferably using the splice method with the proviso that when data1 has 3 elements it jumps to data2 and adds 3 elements and when data2 has 3 elements it jumps to data3 and adds to arr .length equals 0. That's what I wanted to say since yesterday but I'm a beginner in this world. I know it's not too difficult but I tried and I could not. A thousand excuses to all who have already answered my question.
What I want is to create a function so I can add the elements to the 3 empty arrays at the same time. Exactly I do not want to copy the arr elements I want to get from an array and add to the empty arrays. for example I get the first 3 indices and add it to array1, I get 3 indices and add it to array2, I get the last 3 indices and add it to array3 but all at the same time.
I want to create a simple card game but with images so I have this array of images and the divs with different class representing each player as I could not pass the images directly to the divs I decided to create 4 arrays for each player but there tb had problem pk n could implement the loop. In the game I have to shuffle the cards, give the cards, predict the plays, add up the value of the cards, what can I do with javascript? In your opinion, what is the best way to do it?
var arr = [];
arr[0]='<img class="images" src="1.jpg">';
arr[1]='<img class="images" src="2.jpg">';
arr[2]='<img class="images" src="3.jpg">';
arr[3]='<img class="images" src="4.jpg">';
arr[4]='<img class="images" src="5.jpg">';
arr[5]='<img class="images" src="6.jpg">';
arr[6]='<img class="images" src="7.jpg">';
arr[7]='<img class="images" src="8.jpg">';
arr[8]='<img class="images" src="9.jpg">';
arr[9]='<img class="images" src="10.jpg">';
arr[10]='<img class="images" src="11.jpg">';
arr[11]='<img class="images" src="12.jpg">';
The result would be this:
js
var data1 = ['elemento1','elemento2','elemento3'];
var data2 = ['elemento4','elemento5','elemento6'];
var data3 = ['elemento7','elemento8','elemento9'];
var data4 = ['elemento10','elemento11','elemento12'];
html
<div id="geral" >
<div id="posi1" class="div_um"></div>
<div id="posi2" class="div_dois"></div>
<div id="posi3" class="div_tres"></div>
<div id="posi4" class="div_quatro"></div>
</div>