quote:
Originally posted by markee
code:
var lyricsArray = new Array("Come fly with me, lets fly, lets fly away","Can't buy me love","Yesterday, all my troubles seemed so far away");
var selectedArray = new Array();
function chooseRandomLyric(){
var i = Math.round(Math.random()*(lyricsArray.length-1));
var j;
Inner:
for(j=0;j<selectedArray.length;j++){
if(i==selectedArray[j]){
i=Math.round(Math.random()*lyricsArray.length);
continue Inner;
}
}
if(selectedArray.length === 10){
selectedArray.pop;
}
selectedArray.concat(i,selectedArray);
return i;
}
this option maybe nicer...
but it might be easier to use a function you understand...
and I doubt the thread starter understands how exactly your function works...