Created
October 1, 2020 14:35
-
-
Save ilovelili/4123171991114b5cb9dba5208b062b99 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<script> | |
function leapYear(year) { | |
return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0; | |
} | |
function checkDaysinMonth(month) { | |
const year = new Date().getFullYear(); | |
switch (month) { | |
case 1: | |
return 31; | |
case 2: | |
return leapYear(year) ? 29 : 28; | |
case 3: | |
return 31; | |
case 5: | |
return 31; | |
case 7: | |
return 31; | |
case 8: | |
return 31; | |
case 10: | |
return 31; | |
case 12: | |
return 31; | |
default: | |
return 30; | |
} | |
} | |
alert(checkDaysinMonth(5)); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment