This commit is contained in:
@@ -45,10 +45,21 @@
|
||||
const inputEl = document.querySelector('.input-year');
|
||||
const outputEl = document.querySelector('.output');
|
||||
|
||||
const isLeapYear = (year) => {
|
||||
const checkOne = year % 400 === 0;
|
||||
const checkTwo = year % 100 !== 0 && year % 4 === 0;
|
||||
return checkOne || checkTwo;
|
||||
};
|
||||
|
||||
let output = '';
|
||||
|
||||
inputEl.addEventListener('input', (e) => {
|
||||
const val = e.currentTarget.value;
|
||||
|
||||
// TODO: check if it is a leap year or not.
|
||||
output = isLeapYear(val) ? `${val} ist ein Schaltjahr` : `${val} ist KEIN Schaltjahr`;
|
||||
|
||||
console.log(output);
|
||||
outputEl.textContent = output;
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user