math.floor(math.random() * array.length) reactjs code example Example: get random element from array js var item = items[Math.floor(Math.random() * items.length)];