Last active
July 24, 2021 09:17
-
-
Save louicoder/f34176e795bc2b6cdf9b75d1832e4eb9 to your computer and use it in GitHub Desktop.
Quiz functions to be added to animation quizzes
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
/** | |
* Function picks random number of specified elements in an array and will return | |
* random (n) numbers from the array length | |
* | |
* @param {Array} [arr=[...Array(100).fill().map((el,i) => i+1)]] - array of elements | |
* @param {Number} [count=7] - count of elements to be picked | |
*/ | |
const pickRandomArrayElements = (arr, count = 7) => { | |
let _arr = [ ...arr ]; | |
return [ ...Array(count) ].map(() => _arr.splice(Math.floor(Math.random() * _arr.length), 1)[0]); | |
}; | |
// const pickRandomElement = (array, ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment