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.
Hello this is my attempt for the problem in javascript. I am getting 11 test cases wrong and I am not sure what I am missing. If anyone can please help, please let me know.
functiondayOfProgrammer(year){// Write your code hereconstdaysInMonth=(year,month)=>newDate(year,month,0).getDate();letdaySum=0;letmonth=0;letisJulian=year<=1917;letisLeapYear=isJulian?(year%4==0):(year%400==0&&year%4==0&&year%100!=0);letisTransitionYear=year==1918;for(leti=0;i<12;i++){letdaysInOneMonth=daysInMonth(year,i);if(daysInOneMonth+daySum>=256){month=i+1;break;}daySum+=daysInOneMonth;}letdays=256-daySum-(isTransitionYear?14:(isLeapYear?1:0));letdateFormating=(number)=>number<10?`0${number}`:number;return`${dateFormating(days)}.${dateFormating(month)}.${dateFormating(year)}`}
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 →
Hello this is my attempt for the problem in javascript. I am getting 11 test cases wrong and I am not sure what I am missing. If anyone can please help, please let me know.