In one of my previous posts I’ve shown you how to get a random item from an array in PHP. Well, there is, of course, a way to do this in JavaScript as well. And it’s also very easy. Just declare someting like this:
<script> var allItems = ['A', 'B', 'C', 1, 2, 3, 4, 5]; </script> |