Guest User

Untitled

a guest
Jan 20th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. const sampleSize = 2
  2. const randomIndex = (array) => Math.floor(Math.random() * array.length)
  3.  
  4. this.moduleCollection$.doc(module.id).collection('questions').valueChanges()
  5. .map(r => r[randomIndex(r)])
  6. .repeat()
  7. .scan((a, c) => a.indexOf(c) === -1 ? a.concat(c) : a, [])
  8. .skipWhile(array => array.length < sampleSize)
  9. .take(1)
  10. .subscribe(res=>{
  11. console.log(res);
  12. })
Add Comment
Please, Sign In to add comment