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 :: how to scroll element in javascript 
Javascript :: jquery equivalent of number_format( 
Javascript :: js 1 second sleep 
Javascript :: clear console javascript 
Javascript :: javascript add button 
Javascript :: popper js 
Javascript :: newtonsoft json parse string 
Javascript :: polymorphism js 
Javascript :: how to convert string into int js 
Javascript :: append javascript variable to html 
Javascript :: jsx attributes 
Javascript :: how to remove duplicates in js 
Javascript :: generate a link with javascript 
Javascript :: js array append 
Javascript :: javascript timer countdown with seconds 59 
Javascript :: react native file pdf to base64 
Javascript :: Jenkins parse json keep order 
Javascript :: javascript Non-numeric String Results to NaN 
Javascript :: javascript Update Values of Properties 
Javascript :: JavaScript Destructuring - Before ES6 
Javascript :: electron InitializeSandbox() called with multiple threads in process gpu-process. 
Javascript :: ejs split string 
Javascript :: chart js svg word map 
Javascript :: javasrcipt jpg resize 
Javascript :: js file not show update 
Javascript :: phaser animation on start event 
Javascript :: Pretty-Print JSON within Neovim 
Javascript :: check notification permissopn allow or not 
Javascript :: white space below image next image 
Javascript :: .pop javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =