Q:

Write a JavaScript program to get a random element from an array

0

Write a JavaScript program to get a random element from an array.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

const sample = arr => arr[Math.floor(Math.random() * arr.length)];
console.log(sample([3, 7, 9, 11]));

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now