Skip to content

Instantly share code, notes, and snippets.

@nabrown
Last active April 9, 2018 12:53
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/70eda53b21244afce4e83872c4b5f4e7 to your computer and use it in GitHub Desktop.
Save nabrown/70eda53b21244afce4e83872c4b5f4e7 to your computer and use it in GitHub Desktop.
An incorrect implementation of a getRandosFromArray function
export const getRandosFromArray = function(arr, numRandos){
let arrClone = arr.slice(0)
let randos = []
for (let i = 0; i < numRandos; i++){
let rand = Math.floor(Math.random() * arrClone.length)
randos.push(arrClone.splice(rand,1))
}
return randos
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment