The message for leap year is not appearing in the designated element
Uncertain why the message isn't showing after the for loop
const year = [2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, 2031, 2032];
for (var i = 0; i < year.length; i++) {
if ((year[i] % 100 === 0) || (year[i] % 100 != 0) && (year[i] % 4 == 0)) { //Iterates through the 'year' array
document.getElementById('results').innerHTML = year[i] + " is a Leap year" + "<br>"); //inserts the message into the inner HTML of ID results
} else {
document.getElementById('results').innerHTML = year[i] + " is not a Leap year" + "<br>"); //inserts the message into the inner HTML of ID results
}
}
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Leap Year Array</title>
<style>
body {
background-color: powderblue;
text-align: center;
}
</style>
</head>
<body>
<h1>Check Leap Year from an Array List</h1>
<br>
<p>This is my Array List: 2020, 2021, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, 2031, 2032</p>
<p>Result:</p>
<p id="results"></p>
</body>