Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const sampleSize = 2
- const randomIndex = (array) => Math.floor(Math.random() * array.length)
- this.moduleCollection$.doc(module.id).collection('questions').valueChanges()
- .map(r => r[randomIndex(r)])
- .repeat()
- .scan((a, c) => a.indexOf(c) === -1 ? a.concat(c) : a, [])
- .skipWhile(array => array.length < sampleSize)
- .take(1)
- .subscribe(res=>{
- console.log(res);
- })
Add Comment
Please, Sign In to add comment