+ 6
Condition is if year%4==0 and year%100 != 0 year is a leap year else if year%400==0 year is a leap year else year is not a leap year
6th Mar 2022, 7:38 PM
Jayakrishna 🇮🇳
+ 4
1900 is divisible by 4 and 100 but it is not a leap year.
6th Mar 2022, 7:53 PM
Jayakrishna 🇮🇳
+ 2
Your if is wrong, it should be more like this: if (x % 4 == 0 || x % 400 == 0)
6th Mar 2022, 7:38 PM
Paul
Paul - avatar
+ 1
Years multiple of 100 are century years 1000,1100,1200, .., 1900,2000,.. are divisible by 4 and 100 but all not leap years 1900 is divisible by 100 but not leap year. 2000 is divisible by 100 but leap year. Using || (or) operator result true if any one condition is true, no need both. Leap Year must be divisible by 4 but not divisible by 100 Or Leap Year must divisible by 400
6th Mar 2022, 8:44 PM
Jayakrishna 🇮🇳
+ 1
No. It says leap year for 1900 simple it should be divisible of 4 and not divisible by 100 . otherwise divisible by 4 and 400... Else cases not a leap year..
6th Mar 2022, 8:52 PM
Jayakrishna 🇮🇳
+ 1
Make changes as I mentioned in my first post. It works. Otherwise don't work.
6th Mar 2022, 9:01 PM
Jayakrishna 🇮🇳
0
Still not get it? See this, https://www.almanac.com/content/when-next-leap-year You're welcome..
6th Mar 2022, 9:17 PM
Jayakrishna 🇮🇳
0
Your Mom you can condense your code to: function Leap_Year() { document.getElementById("demo").innerHTML = !((yr % 4) || (!(yr % 100) && yr % 400)) ? "Leap Year": "Not a Leap Year"; } Or use Date, and check if February have 29 https://code.sololearn.com/WslBGD5wir7k/?ref=app
7th Mar 2022, 1:30 PM
Bob_Li
Bob_Li - avatar
- 1
const leap_year = year%4&&year100!=0?year%400?yes:yes:no
8th Mar 2022, 7:36 AM
Shaishab Chandra Shil
Shaishab Chandra Shil - avatar
- 1
Can anyone create new code for me Because my has so many errors
8th Mar 2022, 6:40 PM
sai sai
- 2
Divide by 4 and then by 400. If there is no reminder then Leap Year else no leap year.
8th Mar 2022, 8:56 AM
Sanjay Kamath
Sanjay Kamath - avatar