0

I'm in the most javascript class and I really don't understand it and I'm stumped on this question. I have trying many different ways for quite a while now, but just can't seem to figure it out. Problem: Here are the rules to determine if a particular year is or is not a leap year: Any year that is divisible by 400 is a leap year. Of the remaining years, any year that is divisible by 100 is not a leap year. Of the remaining years, any year that is divisible by 4 is a leap year. All other years are not leap years. Write JavaScript code that reads a year from the user and displays either Leap year or Not a leap year, whichever is correct.

Thanks for your help!

1 Answers1

1

This should work

function leapYear(year)
{
  return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
}

I got the above from the weblink below. Please make sure you check to see if your question has been previously asked and answered. If a similar question has been asked, it is good to explain why the answer does not work for you. Hope this helps.

Check if year is leap year in javascript

P.S. Welcome to SO.

J Weezy
  • 3,507
  • 3
  • 32
  • 88
  • 1
    If the question is answered completely in another question, don't post an answer, just flag it as a duplicate. – Barmar Mar 29 '18 at 22:05