Tell us what’s happening:
I think this code can work, but the result is different
Your code so far
function isLeapYear(year){
const isLeap = year % 400 === 0 || year % 4 === 0 && 100 !== 0;
return `${year} ${isLeap ? 'is ':'is not '}a leap year.`;
}
const year = 1900;
const result = isLeapYear(year);
console.log(result);
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:152.0) Gecko/20100101 Firefox/152.0
Challenge Information:
Build a Leap Year Calculator - Build a Leap Year Calculator
GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-leap-year-calculator/66c06fad3475cd92421b9ac2.md at main · freeCodeCamp/freeCodeCamp · GitHub
ILM
June 29, 2026, 6:48am
2
consider in what order do you want these expressions to run
and then consider what is the relative priority of || vs &&
is relative priority like operator precedence ?
Yes, relative priority is like operator precedence.
I think the phrase year % doesn’t necessarily have to be repeated after the 100. It’s similar to the use of “and” in formal language. for example : If “I want to buy coffee and bread”, I don’t need to repeat “I want to buy” before the word “bread”. Is that correct ?
ILM
June 29, 2026, 8:18am
6
that’s not correct, you are doing once year % 400 and once year % 4, if you remove the % you are not using it anymore
I suggest you focus on && and ||
but now the code is work with && year % 100 without worrying about operator precedence hhe. the order of operator precedence begin first with && and next with ||. is that correct ?
ILM
June 30, 2026, 6:21am
8
yes, the order in which this code runs:
year % 400 === 0 || year % 4 === 0 && 100 !== 0
is
(year % 400 === 0) || (year % 4 === 0 && 100 !== 0)
when in doubt you can use brackets so the expressions go in the order you want for sure