This commit is contained in:
@@ -37,8 +37,42 @@
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
const year = Number(prompt('please enter year:'));
|
||||
const year = Number(prompt('Gib ein Jahr ein:'));
|
||||
const outputEl = document.querySelector('.output');
|
||||
|
||||
if (year % 400 === 0) {
|
||||
console.log(`${year} ist ein Schaltjahr.`);
|
||||
} else if (year % 100 === 0) {
|
||||
console.log(`${year} ist KEIN Schaltjahr.`);
|
||||
} else if (year % 4 === 0) {
|
||||
console.log(`${year} ist ein Schaltjahr.`);
|
||||
} else {
|
||||
console.log(`${year} ist KEIN Schaltjahr.`);
|
||||
}
|
||||
|
||||
// if (year % 400 === 0) {
|
||||
// outputEl.innerHTML = `${year} ist ein Schaltjahr.`;
|
||||
// } else if (year % 100 === 0) {
|
||||
// outputEl.innerHTML = `${year} ist KEIN Schaltjahr.`;
|
||||
// } else if (year % 4 === 0) {
|
||||
// outputEl.innerHTML = `${year} ist ein Schaltjahr.`;
|
||||
// } else {
|
||||
// outputEl.innerHTML = `${year} ist KEIN Schaltjahr.`;
|
||||
// }
|
||||
|
||||
const checkOne = year % 400 === 0;
|
||||
const checkTwo = year % 100 !== 0 && year % 4 === 0;
|
||||
let output = '';
|
||||
|
||||
// if (checkOne || checkTwo) {
|
||||
// output = `${year} ist ein Schaltjahr!`;
|
||||
// } else {
|
||||
// output = `${year} ist kein Schaltjahr`;
|
||||
// }
|
||||
|
||||
// outputEl.innerText = output;
|
||||
|
||||
outputEl.textContent = checkOne || checkTwo ? `${year} ist ein Schaltjahr!` : `${year} ist kein Schaltjahr`;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user