I'm in the process of coding a simple BlackJack game in Javascript. So far, I have an array like this:
var deckArray = [ "card1", "card2",...,"card52" ]
I have a "deal" function set up like this:
var deal = function(){
var card = Math.floor(Math.random() * deckArray.length);
return deckArray.splice(card,1)[0];
};
Since I'm already using Math.random to randomly choose from the deckArray, would it be redundant for me to incorporate a "shuffle" function with Lodash like this?
var shuffle = function(){
deckArray = _.shuffle(deckNames);
};
deal
function. – DurmanMath.random
: github.com/lodash/lodash/blob/master/shuffle.js – Buddhology