getElementbyId contn'd

i have a script that outputs 4 random images from a folder:

var imagenumber = 9 ;
var randomnumber = Math.random() ;
var rand1 = Math.round( (imagenumber-1) * randomnumber) + 1 ;

var randomnumber2 = Math.random() ;
var rand2 = Math.round( (imagenumber-1) * randomnumber2) + 1 ;

var randomnumber3 = Math.random() ;
var rand3 = Math.round( (imagenumber-1) * randomnumber3) + 1 ;

var randomnumber4 = Math.random() ;
var rand4 = Math.round( (imagenumber-1) * randomnumber4) + 1 ;

the 4 random images generated are inserted into 4 seperate divs (<div id=“highlight_1”><div id=“highlight_2”><div id=“highlight_3”><div id=“highlight_4”>.

the question i have is, how can you make the output have each of the 4 images different from each other (no repeats on the page)? i always get duplicate random numbers. any ideas?

If you want to ensure uniqueness of your randomly generated numbers, the easiest way would be to assign the value to a variable or an array and then check on each subsequent generation if the number generated has been generated previously and if so, generate a new one until you get something unique.

You have to track what you have already generated.