MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/b2o6f2/whats_your_favorite_most_useful_javascript/eiull1d/?context=3
r/javascript • u/Linux_is_awesome • Mar 18 '19
422 comments sorted by
View all comments
8
personal favorite: var item = items[Math.floor(Math.random()*items.length)];
var item = items[Math.floor(Math.random()*items.length)];
It randomly selects an element from an array.
1 u/jseego Mar 19 '19 Check out this article:http://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array
1
Check out this article:
http://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array
8
u/Linux_is_awesome Mar 18 '19
personal favorite:
var item = items[Math.floor(Math.random()*items.length)];It randomly selects an element from an array.