So I am trying to merge two arrays into one object. More specifically I am creating a deck of cards using JavaScript. I have created the two arrays (shown below) and am looking for some help on how to merge them so that the new object will be formatted like this {suit: 'hearts', value: 'A'}. I believe i need to do a for loop but haven't been able to make it work. Anyone have any suggestions?
// ... trying to merge the two arrays here ...
function deck_o_cards() {
var values = [2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'A'];
var suits = ['hearts', 'diamonds', 'clubs', 'spades'];
var cards = [ ];
for(i=0, i< suits.length, i++){
var newSuit = suits[i];
for(a=0; a< values.length, a++) {
var newValue= values[a];
newArray=[newSuit, newValue];
cards.push(newArray);
}
}
}