Randomly place object on array element

I'm making a sort of "scratch and win" game using canvas elements. The things is, I've now come to a halt thinking about the best way to possibly make the game recognize a winner state.

I have an array os 9 canvas elements and I want to be able to RANDOMLY choose 3 of them to place a background image (which is just a visual representation of the 3 required parameters for the "prized" element).

So, let's say I want to be able to choose the 3 canvas elements from the array and place a background image in each one. Since I'm using Node.JS/Socket.io and the "controller" is supposed to be a mobile device (phone or tablet) how can I make sure that everything is in sync, so that the randomly chosen elements on the "client" are the same on the "controller"? And how would I use a truly random state?

Hope this description is enough, but I can post some code if necessary.

I think it will be interesting to see what your opinions are.

Best Regards, Celso Santos

You will need to communicate the chosen indexes from the server to the client. I'm not sure what the best randomizer is for javascript, but that should be trivial to figure out.

Then just select 3 indexes on the server in node.js and pass them to the client. The client then does displays the correct images in the correct canvases while all the data stays on the server.

For these type of games you will want to make all important decisions on the server side. This way, users can't meddle with the data on their side, since the server checks the integrity.