# JS example example of generating randomly chaos arrays

The example of this paper tells the method of JS generation random disruption array. Share to everyone for your reference, specifically:

``` function fnluanxu (NUM) { VAR aluanxu = []; for (var i = 0; i ``` < num; i++) {
aLuanXu[i] = i;
}
for (var i = 0; i < num; i++) {
var iRand = parseInt(num * Math.random());
var temp = aLuanXu[i];
aLuanXu[i] = aLuanXu[iRand];
aLuanXu[iRand] = temp;
//console.log('i='+i+';temp='+temp+';rand='+iRand+';array['+i+']='+aLuanXu[i]+';array['+iRand+']='+aLuanXu[iRand]+';array=['+aLuanXu+'];');
}
return aLuanXu;
}
//测试：
console.log(fnLuanXu(6));

``` ```
Operation result: Second, the sorting method is less chaotic, the JS built-in function.

Function Fnluanxu (NUM) {var aluanxu = []; for (var i = 0; i
0.5? -1: 1;}) Return aluanxu;} // Test: console.log (Fnluanxu (7));
` `  ` Operation results:`
PS: Here you will provide you with several related online tools for your reference:

Online random numbers / String generation tool: http://tools.jb51.net/aideddesign/suijishu

Online English Depending on the letter sorting tools:

http: //Tools.jb51.net/aideddsign/en_paixu
online text reverse flip sorting tool:

http://tools.jb51.net/aidedDesign/flipped_txt
About JavaScriptContent Interested readers can view this topic: “JavaScript Mathematical Computing Summary”, “JavaScript Data Structure and Algorithm Skill Summary”, “JavaScript Array Operation Skill Summary”, “JavaScript Sort Algorithm Summary”, “JavaScript Overall Algorithm Strike Summary, “JavaScript Find Algorithm Skill Summary” and “JavaScript Error and Debugging Skill Summary”