9951 explained code solutions for 126 technologies


javascriptGet random element from array


arr[ Math.floor(Math.random() * arr.length) ]ctrl + c
arr

array to get random element from

Math.floor

will return lower closest integer for the specified float number

Math.random

returns random float from 0 to 1