**Task at hand: determine if a year is a leap year. ** My idea was to try to have a user enter a year (four digits only), then send that info to javascript, so it can be used in my isLeapYear function. My function works only if I neglect the info provided by the user and only use console.log with different years. Any guidance is truly appreciate. Trying to learn to code, but I get overwhelmed and discouraged, so I stop (any guidance on this as well? How do you keep motivated?)
<!--HTML-->
<!DOCTYPE html>
<html lang = "en">
<head>
<title> Is it leapyear </title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="leapyear.js"></script>
</head>
<body>
<p> Enter year </p>
<input type="numbers" id="leapYear" placeholder="enter a 4 digit year-YYYY" maxlength="4" pattern="\d{4}"/>
<button type="submit">Submit</button>
</body>
</html>
//JAVASCRIPT
var year = document.getElementById("leapYear").value;
function isLeapYear(year) {
if ( ( year % 4 == 0 && year % 100 != 0 ) || (year % 400 == 0) ) {
console.log(`${year} is a leap year`);
} else {
console.log(`${year} is not a leap year`);
}
}
//console.log(isLeapYear(2023));