Created
February 4, 2014 18:48
-
-
Save LESTADru/8809805 to your computer and use it in GitHub Desktop.
функцию sort для того, чтобы «перетрясти» элементы массива в случайном порядке.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>функцию sort для того, | |
чтобы «перетрясти» элементы массива в случайном порядке.</title> | |
</head> | |
<body> | |
<script> | |
'use strict' | |
var arr = [1, 2, 3, 4, 5]; | |
function rndSort(a, b){ | |
return Math.random() -0.5; | |
} | |
arr.sort(rndSort); | |
alert(arr); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment