programming-examples/js/Array/Write a JavaScript function to get a random item from an array..js

9 lines
193 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
function random_item(items)
{
return items[Math.floor(Math.random()*items.length)];
}
var items = [254, 45, 212, 365, 2543];
console.log(random_item(items));