I need to populate three arrays with different values for the same range.
For ex:
Have an array like this
var arr = [1,2,3,4,5,6];
i need this array in format
a[0]=[2,3,4,1,5];
a[1]=[4,3,2,1,5];
a[2]=[2,3,1,5,4];
so three indexes of array show three different array values in order.
I am trying with this below snippets
(function($){
$.fn.shuffle = function() {
return this.each(function(){
var items = $(this).children();
return (items.length)
? $(this).html($.shuffle(items))
: this;
});
}
$.shuffle = function(arr) {
for(
var j, x, i = arr.length; i;
j = parseInt(Math.random() * i),
x = arr[--i], arr[i] = arr[j], arr[j] = x
);
return arr;
}
})(jQuery);
var arr = [1,2,3,4,5,6];
a =[];
b=[];
c=[];
a = $.shuffle(arr);
b = $.shuffle(a);
c = $.shuffle(b);
document.write(a);
document.write(b);
document.write(c);