Originally Posted by Krupski
parseInt defaults to base 10 so it does the same thing as Math.floor.
parseInt doesn't always default to base 10 - sometimes it defaults to base 8.
The difference between using the function intended to convert to integer Math.floor(x) and one that does so as a side effect but which is actually intended for a different purpose parseInt(x,10) is the same difference as there is between driving a Ford to work or driving a Cesna to work - one is intended for that purpose and the other is intended to be used for something different.
Just watch out that you don't get your wings knocked off next time you drive your Cesna to work.
In particular parseInt should NEVER be used where dates are concerned because of the danger that it will treat numbers as base 8 instead of base 10 and so will fail to work on the 8th and ninth of each month as well as failing completely for August and September. I have lost count of the number of forum questions I have answered where this problem occurred because someone misused parseInt.
Anyway that code you posted with 15 lines in the function is about 13 lines longer than necessary as I showed in my following post where including the actual call to the function my solution used only 3 lines of code to do the same thing.
Helping others to solve their computer problem at http://www.felgall.com/