Javascript on repeat image generator | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Javascript on repeat image generator

I want to write an image generator, there are 10 images in total and it will display 5 images randomly each time without repeating, I've tried math.floor(math.random()*10), but it will repeat sometime, any ideas???

8th Dec 2019, 3:18 PM
Maple
1 Answer
+ 1
Try this: https://code.sololearn.com/WlVNAc0l2hbF/ You need to remove the image from the array when you use it so it can’t be used again. array.splice(index, 1) will do exactly that for you
8th Dec 2019, 3:59 PM
Jax
Jax - avatar