Created
June 25, 2012 23:23
-
-
Save tsterker/2992068 to your computer and use it in GitHub Desktop.
[js] remove random elements from array
This file contains hidden or 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
var l = [1,2,3,4,5,6,7,8,9,10]; | |
while(l.length){ | |
var r = (Math.random()*1000)%l.length; | |
var removed = l.splice(r, 1); | |
console.log('Removed: ' + removed); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment