I have a script that is (seemingly) randomly stopping at the end of a for loop. It completes each iteration, and it completes everything within each iteration, but then it mysteriously stops. As you can see, the "Moving on" alert never fires. ANY help is appreciated!
CODE:
var sliderDirectionRaw = "top-left,left";
var sliderDirection = sliderDirectionRaw.split(",");
for (i=0;i<=sliderDirection.length;i++) {
if (sliderDirection[i].indexOf("-") >= 0) {
sliderDirection[i] = sliderDirection[i].split("-");
alert("Multiple directions specified in iteration "+i);
}
alert("Direction iteration "+i+" finished");
if (i == sliderDirection.length-1) {
alert("Direction loop finished");
}
}
alert("Moving on from Direction loop");
JSFiddle: http://jsfiddle.net/k7cSE/1/
console.log("my message"). In firefox or Chrome you can press F12 to open the console. The error messages show up in the console as well.TypeError: sliderDirection[i] is undefinedno mystery, just an error in your JavaScript.