Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

leap year condition in javascript

//Easiest Leap-year condition
function isLeapyear(year){
    if(year%4==0  ||  year%400==0   &&   year%1000!=0){
        return true;
    }
    else{
        return false;
    }
}


const my_year = isLeapyear(1999);  //Tip: 2000 is a leap year.

console.log('My year is', my_year );
Comment

javascript leap year

function isLeapYear(year){
	if(year % 400 === 0 && year % 4 === 0){
      return true
    } else {
      return false
    }
}
Comment

Leap year function javascript

function isLeapYear(year) {
    if (year % 4 == 0) {
        console.log("leap year")
    } else {
        console.log("Not a leap year")
    }
}
var myYear = 2020;
isLeapYear(myYear)
// Output:leap year
Comment

javascript Program to check if a given year is leap year

<script>
 
// Javascript program to check
// for a leap year
 
    function checkYear( year) {
        // If a year is multiple of 400,
        // then it is a leap year
        if (year % 400 == 0)
            return true;
 
        // Else If a year is multiple of 100,
        // then it is not a leap year
        if (year % 100 == 0)
            return false;
 
        // Else If a year is multiple of 4,
        // then it is a leap year
        if (year % 4 == 0)
            return true;
        return false;
    }
 
    // Driver method
      
        let year = 2000;
        document.write(checkYear(2000) ? "Leap Year" : "Not a Leap Year");
 
 
// This code is contributed by shikhasingrajput
 
</script>
Comment

PREVIOUS NEXT
Code Example
Javascript :: json to csv 
Javascript :: how to detect click outside input element javascript 
Javascript :: js array join 
Javascript :: component will mount hooks 
Javascript :: alpinejs 
Javascript :: jquery modal popup 
Javascript :: json date format 
Javascript :: replace spaces with dashes 
Javascript :: javascript Arrow Function with No Argument 
Javascript :: set tiemzone datetime object 
Javascript :: index.js:1 You have included the Google Maps JavaScript API multiple times on this page. This may cause unexpected errors. 
Javascript :: react native intro slider 
Javascript :: toggle buttons angular styles 
Javascript :: json html 
Javascript :: delete value from an array javascript 
Javascript :: javascript dom methods 
Javascript :: instantiate js 
Javascript :: break loop if condition is met 
Javascript :: scrollintoview 
Javascript :: javascript validator 
Javascript :: javascript infinity 
Javascript :: react native image border radius not working 
Javascript :: plus operator javascript 
Javascript :: terjemahan 
Javascript :: if is a string javascript 
Javascript :: javascript code for find the last element in array 
Javascript :: req.body 
Javascript :: stripe payment js 
Javascript :: destructuring javascript 
Javascript :: replace element javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =