I can't figure out why my recursive timeout function will only go through these images only once. It keeps ending even though I have reset the variable 'n' in the "else" statement. The goal of this is to change the z-scores of the images to swap them out.
var n = 0;
window.onload = imageFade;
function imageFade(){
for(x=0; x<10; x++){
document.getElementById("image" + x).style.zIndex = 0;
}
timeout();
}
function timeout() {
setTimeout(function(){
if(0 <= n <= 9){
document.getElementById("image" + n).style.zIndex = 1;
n++;
timeout();
}else{
n=0;
timeout();
}
}, 1000);
}