Solution for count days in JavaScript