samedi 23 novembre 2019

Array Random Values without repeating array in loop

How can I loop through all the entries in an array using JavaScript? I have an array and i want an another array of randoms list in arrRand variable and then execute my further code .

 list1 = ['aceClub', 'twoClub'];
 list2 = ['fourDiamond', 'aceClub', 'fourHeart', 'twoDiamond'];
 list3 = ['aceHeart', 'aceClub', 'aceHeart', 'aceDiamond'];
 list4 = ['aceDiamond', 'fourSpade', 'twoClub', 'fourHeart'];
 list5 = ['fourClub', 'twoSpade' , 'twoHeart', 'aceDiamond'];
 list6 = ['twoHeart', 'twoDiamond' , 'twoSpade' , 'aceClub'];

 var arr = [list1,list2,list3,list4, list5,list6];

i want this in array of randoms .

var arrRand = [list5,list6,list2,list4, list3,list1];
var arrRand = [list3,list2,list6,list5, list1,list4];
var arrRand = [list1,list5,list2,list4, list6,list2];

and then

if(arrRand[0] == list1){
   //mycode 
}
if(arrRand[1] == list2){
  //myCode
}
....



Aucun commentaire:

Enregistrer un commentaire