I searched for it, but all the answers are pretty old so maybe there is a better way. I\'m trying to get a random item from a Firebase DB which looks like this:
First you have retrieve all the userid from the firebase.
Then declare an array that stores all the userid in it. Below shows on how to store the userId.
var arr = new Array();
// or var arr = [];
arr.push('user001');
arr.push('user002');
Next you have to select randomly from one of the userId.
var item = arr[Math.floor(Math.random()*arr.length)];
// item is randomly picked userId
I'm sorry because i didn't completely show you on how the implementation works as I don't use javascript much.
Basically this is how the logic works. I hope it helps you :D