html
html
1
2
3
4
5
6
7
8
9
10
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<pre></pre>
<button onclick="shuffle()">Shuffle again</button>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
body {
}
pre {
white-space: -moz-pre-wrap; /* Mozilla */
white-space: -hp-pre-wrap; /* HP printers */
white-space: -o-pre-wrap; /* Opera 7 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: pre-wrap; /* CSS 2.1 */
white-space: pre-line; /* CSS 3 (and 2.1 as well, actually) */
word-wrap: break-word; /* IE */
word-break: break-all;
}
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function randomNumbersArray(n) {
var nums = [], num;
for (var i = 0; i < n; i++)
{
do {
num = (Math.floor(Math.random() * n));
} while (nums.indexOf(num)!=-1)
nums.push(num);
}
return nums;
}
window.onload = shuffle;
function shuffle() {
var arr = ["One", "Two", "Three", "Four", "Five","Six","Seven","Eight","Nine","Ten"];
var indexes = randomNumbersArray(arr.length);
var output = [];
for(var i=0;i<arr.length;i++) {
output.push(arr[indexes[i]]);
}
var pre = document.querySelector('pre');
pre.innerText = "Input array: " + arr.join(",") + "\n";
pre.innerText += "Shuffle array: " + output.join(",");
}
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run