-1
我想下面後輸入4名打印出來像對: ASD配對,DFS和FSD配對HKG ..打印出數組元素
ASD ==== DFS
FSD == == HKG
function shuffle(o) {
for (var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
};
function myFunction() {
var aname, i = 0,
x, names = [],
arname = [];
x = prompt("Please enter number of list:");
//var y = prompt("Enter digits:");
while (i < x) {
names[i] = prompt("Enter the names:", "");
//names+=names;
//document.getElementById("demo").innerHTML= "The names are " + names;
i++;
}
arname = shuffle(names);
document.getElementById("demo").innerHTML = "The shufled array is " + arname;
}
<p>Click the button to shuffle.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>