+ 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
+ 4
1900 is divisible by 4 and 100 but it is not a leap year.
+ 2
Your if is wrong, it should be more like this:
if (x % 4 == 0 || x % 400 == 0)
+ 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
+ 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..
+ 1
Make changes as I mentioned in my first post. It works. Otherwise don't work.
0
Still not get it? See this,
https://www.almanac.com/content/when-next-leap-year
You're welcome..
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
- 1
const leap_year = year%4&&year100!=0?year%400?yes:yes:no
- 1
Can anyone create new code for me
Because my has so many errors
- 2
Divide by 4 and then by 400. If there is no reminder then Leap Year else no leap year.