It's functional now and doesn't crash.

I got rid of unnecessary functions in the monthObj object. New elements
are created everytime it loops (this was the main problem. Checks for
leap year now too thanks to nmrugg.