//array 1: the suits
var suits = ["clubs","hearts","diamonds","spades"];
//array 2: the ranks
var ranks = [2,3,4,5,6,7,8,9,10,"J","Q","K","A"];
//using for loops, modify the "deck" array so that it becomes a
//two-dimensional array that stores every card in the deck;
//e.g. [1, "clubs"], [2, "clubs"],etc...["A", "spades"]
var deck = [];
for (a=0; a< (ranks.length * suits.length); a++) {
for (b=0; b < ranks.length; b++) {
for (c=0; c < suits.length; c++) {
deck[a] = [ranks[b],suits[c]];
}
}
}
_____________________________________________________________________________________
ASSOCIATIVE ARRAYS
//This is an associative array of the results of the student roll call.
//If the value of the key is false, then the student was absent.
var students = {"robert":false,"joe":true,"sharon":true};
//Loop over the students associative array. If the student was present
//output their name to the console
for (var key in students){
if (students[key]===true){
console.log(key);
}
}
_____________________________________________________________________________________
INDEXED ARRAY OF ASSOCIATIVE ARRAYS
var hand = [{"suit":"clubs","rank":8}, {"suit":"spades","rank":"A"}, {"suit":"hearts","rank":2}, {"suit":"hearts","rank":"K"}, {"suit":"clubs","rank":9}];
_____________________________________________________________________________________