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 read a file in javascript 
Javascript :: angular build production 
Javascript :: require statement not part of import statement 
Javascript :: random positive or negative javascript 
Javascript :: react navigation history clear 
Javascript :: recursion in javascript 
Javascript :: jquery get all inputs in form 
Javascript :: node app listen change ip 
Javascript :: js read file json 
Javascript :: javascript get time 
Javascript :: usecallback vs usememo 
Javascript :: js dictionary to extract the same key bvalues 
Javascript :: vuetify autocomplete get input value 
Javascript :: hide column in antd table using js / react with conditional rendering 
Javascript :: recursive function for fibonacci series in java javascript 
Javascript :: multithreading in javascript 
Javascript :: clear interval js 
Javascript :: jquery post form async 
Javascript :: node -r dotenv/config 
Javascript :: how to stop re rendering in react 
Javascript :: binary tree implementation javascript 
Javascript :: Javascript Show HTML Elements 
Javascript :: How to get the background image URL of an element using jQuery 
Javascript :: material app routes 
Javascript :: clear a div 
Javascript :: how get height elemnt with that margin in js 
Javascript :: vue js routue push 
Javascript :: how to enable javascript 
Javascript :: how to emty an array in javascript 
Javascript :: Orderby on multiple columns using typeorm 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =