I have 3 images in an array and I randomise the index to generate them randomly but I want to generate each image 4 times. What would be the most efficient way of doing this?
function add_cell_image(cell)
{
for(var i = 0; i <= image_array.length; i++)
{
for(var j = 0; j <= image_array.length; j++)
{
var index = create_values();
cell.innerHTML = "<img class='cell_image' align='middle' width='90' height='90' src ='../images/" + image_array[index] + "'/>";
}
}
}
function create_values()
{
return Math.floor(Math.random() * image_array.length);
}
Aucun commentaire:
Enregistrer un commentaire