I have a link leading to 1 of 6 articles displaying on my website. Every 6 seconds, the text link switches to the next. I'd like for the order to be randomized, though, so that each article has the same likelihood to be chosen. Can anyone help?

My code on gist is here:

The raw code is here:

Thank you in advance.

Recommended Answers

All 2 Replies

Instead of index++ use the Math.random() function. But you should try to avoid the same number being chosen again.

Sounds simple enough, but I have no clue what you're talking about. I should've mentioned that I suck at coding. I'm just good at googling stuff to copy and paste. What should I search for to find a tutorial? Would it be hard to actually implement?

Thank you for the response either way. I truly appreciate it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.