← Back to challenges

Days in a Month

JavaScriptHardconditionsdates

Instructions

Create a function that takes the month and year (as integers) and returns the number of days in that month.

Examples

days(2, 2018) ➞ 28

days(4, 654) ➞ 30

days(2, 200) ➞ 28

days(2, 1000) ➞ 28

Notes

Don't forget about leap years!

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Fix the Spacing