Created
September 21, 2022 09:45
-
-
Save Nasah-Kuma/995174bf7de654d589b58bc518f7b05f to your computer and use it in GitHub Desktop.
Hackerrank Challenge day-of-the-programmer : https://www.hackerrank.com/challenges/day-of-the-programmer/problem?isFullScreen=true
This file contains 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
function dayOfProgrammer(year) { | |
// Write your code here | |
let feb = 0; | |
let initialDaySum = 0; | |
if (year >= 1700 && year <= 1917) { | |
if (year % 4 === 0) feb = 29; | |
else feb = 28; | |
} | |
else if (year > 1918 && year <= 2700) { | |
if (year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0)) feb = 29; | |
else feb = 28; | |
} else { | |
feb = 29 - 14; | |
} | |
initialDaySum = 31 + feb + 31 + 30 + 31 + 30 + 31 + 31; | |
let date = 256 - initialDaySum; | |
return `${date+'.' + '09' + '.' + year}`; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment