xxxxxxxxxx
const leapYear = (year) => {
// Formula to calculate Leap Year
return year % 400 == 0 || year % 4 == 0 && year % 100 != 0
}
const nextLeapYear = () => {
let nextLeap = [] // Declare An Empty Array
let year = new Date().getFullYear() // Get Current Year
while (nextLeap.length < 1){ // While condition to loop until it gets next Leap Year
if (leapYear(year)){ // If found then push it into the array
nextLeap.push(year)
}
year++ // else getting upcoming years to check if it's a leap year
}
return nextLeap
}
console.log(nextLeapYear().toString())