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

Popular posts from this blog

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -