Skip to content

How to get ‘how many days in February’ using Javascript?

It is quite handy to have a function that can tell you how many days there are in February due to the leap year shift of either 28 or 29 days.
Below is a function created in Javascript to return the exact amount of days according to the year given:

function daysInFebruary (year){ return (((year%4==)&&((!(year%100==))||(year%400==)))?29:28); }
Code language: JavaScript (javascript)

See also  How to Solve Max-Min Arrays in Java
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x