Why do you persist in copying the function arguments to other variables?
Why not simply:
Code:
function daysBetween(firstd, secondd, str)
{
var date1 = Date.parse(firstd),
date2 = Date.parse(secondd);
...
And, actually, there's nothing wrong with doing
Code:
function daysBetween(date1, date2, str)
{
date1 = Date.parse(date1);
date2 = Date.parse(date2);
...
And may I point out that you repeated this code:
Code:
date1ms = date1.getTime(); //we convert both dates to milliseconds.
date2ms = date2.getTime();
var thedifference = Math.abs(date1ms - date2ms);
for no apparent reason?
Of course, now you know that you could have done simply
Code:
var thedifference = Math.abs(date1 - date2);