I have a javascript array of Date objects, which I'd like to test for ascendingness. This is what I built, but I am kind of disappointed by it. Any suggestion?
function isAscending(timeLine) {
if (timeLine.length < 2)
return true;
for(var i=1; i < timeLine.length; i++) {
if(timeLine[i-1] > timeLine[i])
return false;
}
return true;
}
(I was hoping for something more expressive, built-in, some library math function etc.)