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;
    return aLuanXu;

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: JS生成随机打乱数组的方法示例


Online English Depending on the letter sorting tools:

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

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”

I hope this article will help you JavaScript programming.

© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment