Skip to content

Instantly share code, notes, and snippets.

@LESTADru
Created February 4, 2014 18:48
Show Gist options
  • Save LESTADru/8809805 to your computer and use it in GitHub Desktop.
Save LESTADru/8809805 to your computer and use it in GitHub Desktop.
функцию sort для того, чтобы «перетрясти» элементы массива в случайном порядке.
<!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