JSFiddle - React, Tailwind, and code Playground

by grc4

JavaScript

var availableCardsForSet = [];
var arrayOne = [];
var arrayTwo = [];

for (var i = 0; i < 12; i++) {
    
    availableCardsForSet[i] = {"cost": i * 100};
    
    //This just sets up an array of objects to use for testing
}


for (var int = 0; int < 10; int++) {

    arrayOne.push(availableCardsForSet.splice(Math.floor(Math.random() * availableCardsForSet.length), 1));
    
    arrayTwo.push(availableCardsForSet.splice(Math.floor(Math.random() * availableCardsForSet.length), 1)[0]);
}


alert(arrayOne[0].cost);

alert(arrayOne[0][0].cost);

alert(arrayTwo[0].cost);