i noticed on the sahi "for loops" documentation page that the for loop variable "i" wasn't being declared with a dollar sign ( $ ):
for (var i=0; i<links.length; i++){
...
so when i wrote a for loop in one of my tests i decided to insert a dollar sign for consistency purposes (so all variables used the dollar sign):
function setTimeFutureHours($hrs) {
...
for(var $i=0; i<$hrs; $i++) {
...
}
}
but when i ran the code, the for loop never ran. i quickly realized that i hadn't put a dollar sign next to the "i" in the middle, so i changed it and it ran perfectly:
function setTimeFutureHours($hrs) {
...
for(var $i=0; $i<$hrs; $i++) {
...
}
}
just out of curiosity, i tried the code without dollar signs next to the "i", like the documentation said and that also worked; you just have to be consistent and either use dollar signs on all of the variables in the for loop phrase or don't use dollar signs ;)
No comments:
Post a Comment