SOURCE

function shuffle(arr){
  var len = arr.length;
  for(var i = 0; i < len - 1; i++){
    var idx = Math.floor(Math.random() * (len - i));
    var temp = arr[idx];
    arr[idx] = arr[len - i - 1];
    arr[len - i -1] = temp;
  }
  return arr;
}

var str1="{Y};{G,Y};";
var str2="{G};{G,R};{G,Y,R};";
var str21=str2.substring(0,str2.length - 1);
console.log(str21);

var n1=str1.split(";");
var n1=shuffle(n1);
var n2=str2.split(";");
var n2=shuffle(n2);
var rank = n1.concat(n2);
console.log(n1);
console.log(n2);
console.log(rank);
console.log(str21);


console 命令行工具 X clear

                    
>
console