How to write a function to return a random element from an array in Javascript -
function randomelement(array) { return array[math.floor(math.random()*array.length)]; }
got far feel missing something....i'm using const not var , using javascript!
help!
cheers!
i'm such idiot, posted question worked out.....
the code is:
function randomelement(array) { const findrandom = array[math.floor(math.random()*array.length)]; return findrandom; }
Comments
Post a Comment