Why do I get three arrays in the same order while I shuffle them with a shuffle function in a for loop?
var items = ['x', 'y', 'z', 'a', 'b'];
var createSlots = function(slots)
{
slots = slots || 3;
var slotRack = [];
for (var i = 0; i < slots; i++ )
{
slotRack.push(shuffle(items));
}
return slotRack;
}
function shuffle(o){ //v1.0
for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
};
var slotmachine = createSlots();
// returns three arrays with values in the same order... do not want that... :(
console.log(slotmachine);