title: LEAP YEAR validate input for 2104, 2000, 2100, 2001 using JAVASCRIPT
body: <p>Find if a year is a leap year or not using the if...else statements described above. Validate your program for the following input: 2104 (true), 2100 (false), 2000 (true), 2001 (false). Hint: A leap year is evenly divisible by 4; however, if a year is evenly divided by 100, it is not a leap year, unless the year is also evenly divisible by 400.</p>
  
  <p>Hi I see two alternative solutions. But only one approach gives solution and the other condition fails. Can anyone help why?</p>
  
  <p>Success output </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function leapYear3(year) {
    if ((year % 4 == 0) &amp;&amp; (year % 100 != 0)) {
      console.log('TRUE');
    } else if (year % 400 == 0) {
      console.log('TRUE');
    } else {
      console.log('FALSE');
    }
  }
  console.log(leapYear3(2104)); // True
  console.log(leapYear3(2000)); // True
  console.log(leapYear3(2100)); // False
  console.log(leapYear3(2001)); // False
  
  //Failing : Output
  function leapYear3(year) {
    if (year % 4 == 0) {
      console.log('TRUE');
    } else if ((year % 400 == 0) &amp;&amp; (year % 100 != 0)) {
      console.log('TRUE');
    } else {
      console.log('FALSE');
    }
  }
  
  console.log(leapYear3(2104)); // True
  console.log(leapYear3(2000)); // True
  console.log(leapYear3(2100)); // True
  console.log(leapYear3(2001)); // False</code></pre>
  </div>
  </div>
  </p>
  
  <p>Why this condition is not right 
  <code>((year % 400 == 0) &amp;&amp; (year % 100 != 0))</code> while this code below is right
   <code>((year % 4 == 0) &amp;&amp; (year % 100 != 0))</code></p>