How to set up an array and pick a random element from it?

Sorry, I'm still new to java, and I don't really know how to apply the code from stack overflow to rmmv.


Basically I'm setting up an event (chest) that gives random item from a pool (array with their IDs).


So I come up with something like this:


pool = {12,23,44,56,77};


loot= Random().pool(array.length);


$gameParty.gainItem($dataItems[loot], 1);


of course it doesn't work... can someone show me the proper way?
{ } is an object


[ ] is an array


pool = [12, 23, 44, 56, 77];     


loot = pool[Math.floor(Math.random() * pool.length];


$gameParty.gainItem($dataItems[loot], 1);
Thanks Shaz! That was fast.


But when I run it, the game give "Syntax error, unexpected token ]". 


I don't see anything wrong with the code, is it the game faulty?
Sorry - my mistake - I left out an )


pool = [12, 23, 44, 56, 77];     


loot = pool[Math.floor(Math.random() * pool.length)];


$gameParty.gainItem($dataItems[loot], 1);
Oh right, silly me. How come I didn't notice that. Thanks! It work perfectly.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-set-up-an-array-and-pick-a-random-element-from-it.72832/