Hi,
In my opinion everything depends on the function that selects a random element.
The algorithm can look like this:
1. read all grids values
2. add them to e.g. an array
3. use the function to select a random element from the table
4. click on the -> item to search again in the object
The 'random' function in JS:
https://stackoverflow.com/questions/5915096/get-a-random-item-from-a-javascript-array