This is my code:
var shuffle = function() {
var set = [];
var waiter = [];
var suitset = ["Hearts","Clubs","Diamonds","Spades"];
for (var r = 1;r <= 13;r++) {
for (var s = 0;s < suitset.length;s++) {
card = [];
var cardeval = evalcard(r); //This is an input from another function
card.push(cardeval[0]);
card.push(suitset[s]);
card.push(cardeval[1]);
waiter.push(card);
}
}
while (waiter.length) { //This is what randomizes the deck aka shuffles
set.push(waiter.splice(Math.random() * waiter.length,1));
}
return set;
};
I'm trying to build a matrix of cards (I'm using matrix here as an array of arrays). There will be 52 arrays of card arrays, each of which holds a card number, suit, and value. But after I call the function, card returns as a string and not an array, even though it is defined with array brackers []. Can anyone see what I'm doing wrong here?