NewbieJS11,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
</head>
<body>
<script>
var arr = new Array;
var words = "0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBN";
for (var pp = 0; pp < 20; pp++) {
var rand = Math.round(Math.random() * 80);
var result = "";
for (var num = 0; num < rand; num++) {
var position = Math.floor(Math.random() * words.length);
result += words.substring(position, position + 1)
}
arr[pp] = result
}
var buffer = "";
for (var num2 = 0; num2 < arr.length - 1; num2++)
for (var j = 0; j < arr.length - 1; j++)
if (arr[j].length < arr[j + 1].length || arr[j].length == arr[j + 1].length && arr[j] > arr[j + 1]) {
buffer = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = buffer
}
for (var num3 = 0; num3 < arr.length; num3++) document.write(arr[num3] + "====" + arr[num3].length + "<br/>");
</script>
</body>
</html>
|