Skip to content
Advertisement

Display multiple random images rather than just the one

The code below displays one image from an array at random. I’ve been trying to change it without success to show all the images from the array at random. I’ve used a while loop to generate the random function. The random function works and randomises the whole array but only on image is returned. There are 8 images in the array.

JavaScript

Thank you

Advertisement

Answer

Are you searching for something like these two approaches?

To chose randomly just one image:

JavaScript

Or to randomize all images:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement