Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width">
  6. <title>JS Bin</title>
  7. </head>
  8. <body>
  9.  
  10. <script id="jsbin-javascript">
  11. /**
  12. * Randomize array element order in-place.
  13. * Using Durstenfeld shuffle algorithm.
  14. */
  15. var array=['a','b','c','d','e','f'];
  16. // function shuffleArray(array) {
  17. // for (var i = array.length-1; i > 0; i--) {
  18. // var j = Math.floor(Math.random() * (i+1));
  19. // var temp = array[i];
  20. // array[i] = array[j];
  21. // array[j] = temp;
  22. // }
  23. // return array;
  24. // }
  25. // shuffleArray(array);
  26. var groupa =[];
  27. var groupb=[];
  28. for(var i=0; i<=array.length-1; i++){
  29. if(i<array.length/2){
  30. groupa.push(array[i])
  31. } else{
  32. groupb.push(array[i])
  33. }
  34.  
  35. }
  36. console.log("groupa = "+ groupa)
  37. console.log("groupb = "+ groupb)
  38. function showMatches(group){
  39. for(var i=0;i<=group.length-1;i++){
  40. for(var j=i+1;j<=group.length-1;j++){
  41. console.log("Matches--> " + group[i] +" Vs " + group[j]);
  42.  
  43. }
  44. }
  45. }
  46.  
  47. showMatches(groupa);
  48. showMatches(groupb);
  49. </script>
  50.  
  51.  
  52.  
  53. <script id="jsbin-source-javascript" type="text/javascript">/**
  54. * Randomize array element order in-place.
  55. * Using Durstenfeld shuffle algorithm.
  56. */
  57. var array=['a','b','c','d','e','f'];
  58. // function shuffleArray(array) {
  59. // for (var i = array.length-1; i > 0; i--) {
  60. // var j = Math.floor(Math.random() * (i+1));
  61. // var temp = array[i];
  62. // array[i] = array[j];
  63. // array[j] = temp;
  64. // }
  65. // return array;
  66. // }
  67. // shuffleArray(array);
  68. var groupa =[];
  69. var groupb=[];
  70. for(var i=0; i<=array.length-1; i++){
  71. if(i<array.length/2){
  72. groupa.push(array[i])
  73. } else{
  74. groupb.push(array[i])
  75. }
  76.  
  77. }
  78. console.log("groupa = "+ groupa)
  79. console.log("groupb = "+ groupb)
  80. function showMatches(group){
  81. for(var i=0;i<=group.length-1;i++){
  82. for(var j=i+1;j<=group.length-1;j++){
  83. console.log("Matches--> " + group[i] +" Vs " + group[j]);
  84.  
  85. }
  86. }
  87. }
  88.  
  89. showMatches(groupa);
  90. showMatches(groupb);
  91.  
  92. </script></body>
  93. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement