Last active
April 9, 2018 12:53
-
-
Save nabrown/70eda53b21244afce4e83872c4b5f4e7 to your computer and use it in GitHub Desktop.
An incorrect implementation of a getRandosFromArray function
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
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