Having array of arrays
var a = [[[1, "alpha", "a"],
[2, "beta", "b"]],
[[3, "gama", "c"]],
[[4, "delta", "d"]]];
var b = [];
1) How can I merge a[0]
and a[2]
into b
?
2) How can I shuffle array b
?
This is a shuffle algorithm I am using >>
Array.prototype.shuffle = function() {
for (var i = 0; i < this.length; i++)
this.push(this.splice(Math.random() * (this.length - i), 1)[0]);
return this;
}
with syntax
myArray.shuffle();