Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width">
- <title>JS Bin</title>
- </head>
- <body>
- <script id="jsbin-javascript">
- /**
- * Randomize array element order in-place.
- * Using Durstenfeld shuffle algorithm.
- */
- var array=['a','b','c','d','e','f'];
- // function shuffleArray(array) {
- // for (var i = array.length-1; i > 0; i--) {
- // var j = Math.floor(Math.random() * (i+1));
- // var temp = array[i];
- // array[i] = array[j];
- // array[j] = temp;
- // }
- // return array;
- // }
- // shuffleArray(array);
- var groupa =[];
- var groupb=[];
- for(var i=0; i<=array.length-1; i++){
- if(i<array.length/2){
- groupa.push(array[i])
- } else{
- groupb.push(array[i])
- }
- }
- console.log("groupa = "+ groupa)
- console.log("groupb = "+ groupb)
- function showMatches(group){
- for(var i=0;i<=group.length-1;i++){
- for(var j=i+1;j<=group.length-1;j++){
- console.log("Matches--> " + group[i] +" Vs " + group[j]);
- }
- }
- }
- showMatches(groupa);
- showMatches(groupb);
- </script>
- <script id="jsbin-source-javascript" type="text/javascript">/**
- * Randomize array element order in-place.
- * Using Durstenfeld shuffle algorithm.
- */
- var array=['a','b','c','d','e','f'];
- // function shuffleArray(array) {
- // for (var i = array.length-1; i > 0; i--) {
- // var j = Math.floor(Math.random() * (i+1));
- // var temp = array[i];
- // array[i] = array[j];
- // array[j] = temp;
- // }
- // return array;
- // }
- // shuffleArray(array);
- var groupa =[];
- var groupb=[];
- for(var i=0; i<=array.length-1; i++){
- if(i<array.length/2){
- groupa.push(array[i])
- } else{
- groupb.push(array[i])
- }
- }
- console.log("groupa = "+ groupa)
- console.log("groupb = "+ groupb)
- function showMatches(group){
- for(var i=0;i<=group.length-1;i++){
- for(var j=i+1;j<=group.length-1;j++){
- console.log("Matches--> " + group[i] +" Vs " + group[j]);
- }
- }
- }
- showMatches(groupa);
- showMatches(groupb);
- </script></body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement