We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
functiondayOfProgrammer(year){if(year==1918){// Corner casereturn`26.09.${year}`;}elseif(year>1918){// Calculating Leap year in Gregorian CalendarconstisLeapYear=(year%4==0)&&(year%100!=0)||year%400==0;return`${isLeapYear?12:13}.09.${year}`;}else{// Calculating Leap year in Julian Calendarreturn`${year%4==0?12:13}.09.${year}`;}}// dayOfProgrammer(2000) // leap year -> 12...dayOfProgrammer(1700);// leap year > 13..// dayOfProgrammer(1800) // NOT leap year -> 12-9-1800// dayOfProgrammer(2016) // leap year -> 13-9-2016// dayOfProgrammer(2017) // NOT leap year -> 12-9-2017
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day of the Programmer
You are viewing a single comment's thread. Return to all comments →
My JS solution