so, i am trying to get my script to figure out the relevant last day of the school term. it needs to run until the current date is less than (as in before) the last day of the quarter. it just keeps on running no matter what. ps, i think the problem might be that it isnt resetting the “lastDayofQuarter” (at least outside of the loop). How can i circumvent this? thanks a ton!
var today = new Date();
var lastDayofQuarter=new Date();
var lastDaysofQuarter=new Array();
lastDaysofQuarter[0]=(2009,11,3);
lastDaysofQuarter[1]=(2010,11,10);
lastDaysofQuarter[2]=(2011,4,18);
lastDaysofQuarter[3]=(2011,5,10);
lastDayofQuarter.setFullYear(lastDaysofQuarter[0]);
i=0;
while (lastDayofQuarter<today) {
lastDayofQuarter.setFullYear(lastDaysofQuarter[i]);
i++;
}
These lines are syntactically valid, but they aren’t working as you intend them to work:
The comma operator evaluates both of its operands (from left to right) and returns the value of the second operand. Therefore
(2009, 11, 3)simply returns3.It looks you you want to do: