var Symbols = []; // list of symbols on the machine var slots = []; // each slot contains the index of the symbol it contains var NUMSLOTS = 15; var NUMSYMBOLS = 5; var FLICKERDURATION = 3000; //Milliseconds function randomize(){ var i = 0; for(i; i < NUMSLOTS; i++){ // picks a random symbol from the symbols list and stores it in the slot slots[i] = Math.floor(Math.random()*NUMSYMBOLS); } } function buttonClick(){ randomize(); //figure out what all the slots will change into setInterval(flickerSlots(), 20); //show symbols flickering before showing the result setTimeout(FLICKERDURATION, showResult()); //show the actual resulting symbols } function flickerSlots(){ } function showResult(){ clearInterval(); //stop the flickering } window.onload = function(){ randomize(); // sets all your slots to an initial value before the lever is started }