How can I pick 20 Random Data from Firebase?
Hi
I think this will work well:
- Get all the tags from Firebase as a list. Let the list be X items long.
- Create a new empty list Y (this will be the final list of 20 data items)
- Run a loop 20 times
- In each iteration of the loop, pick a random
n
number between 1 and X. - Get the
n
th element in your list of all tags. - Add this element to list Y.
- Remove that element from the list of all tags.
- Decrement X by 1.
Hope this helps!
In that case, your program gets 20 random tags from FireBase DB. Get values paired with those tags using this block
1 Like
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.