Hi, This is the first time i've posted on here so not sure if i've done it right, but i'm looking for a bit of guidance really. I'm doing an introduction to programming module at university and we are studying Javascript; i've never touched the language before so i'm slowly learning. For one of my lab exercises i have been asked to create a javascript fruit/slot machine, just something basic where you click on the handle and it randomly chooses three images from an array list. I've managed all of that so far; however, for the final question we have to make the images change several times as if they are rotating drums, then eventually stop on a random image. Can anyone point me in the right direction how i should go about doing this? This is the javascript code i have so far, which on double click of the handle chooses three random images...
tim = 0var i = 0var imageSources = new Array; imageSources[0] = "bar.gif" imageSources[1] = "cherry.bmp" imageSources[2] = "lemon.gif" imageSources[3] = "banana.gif" imageSources[4] = "orange.gif" imageSources[5] = "apple.gif" imageSources[6] = "grapes.gif" imageSources[7] = "coins.gif" function randomNumber() { return Math.floor(Math.random()*8); } function load() { var testImage1 = document.getElementById("drum1"); testImage1.src = imageSources[randomNumber()]; var testImage2 = document.getElementById("drum2"); testImage2.src = imageSources[randomNumber()]; var testImage3 = document.getElementById("drum3"); testImage3.src = imageSources[randomNumber()];}function handleup() { var handle1 = document.getElementById("handle") handle1.src = "handle.gif";}function handledown() { var handle2 = document.getElementById("handle"); handle2.src = "handle2.gif"; tim = setTimeout("handleup()", 4000) }