Skip to content

Instantly share code, notes, and snippets.

@nabrown
Last active April 9, 2018 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nabrown/2ac45e448e145d7f40463ddb60bdb119 to your computer and use it in GitHub Desktop.
Save nabrown/2ac45e448e145d7f40463ddb60bdb119 to your computer and use it in GitHub Desktop.
Another implementation of getRandosFromArray function, using shuffled array
export const getRandosFromArray = function(arr, numRandos){
let arrClone = array.slice(0)
let shuffled = arrClone.sort(function() { return .5 - Math.random() })
let randos = shuffled.slice(0, numRandos)
return randos
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment