screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <script> function isLeapYear(year) { if ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0) { return true; } else { return false; } } function checkLeapYear() { var year = document.getElementById("yearInput").value; var result = isLeapYear(year); var output = document.getElementById("output"); output.innerHTML = year + (result ? " is a leap year." : " is not a leap year."); } </script> </head> <body> <h3>Javascript Check if year is leap year</h3> <label for="yearInput">Enter a year:</label> <input type="number" id="yearInput" value="2022" /> <button onclick="checkLeapYear()">Check</button> <p id="output"></p> </body> </html>