This commit is contained in:
Philippe Torrel
2026-09-16 10:38:23 +02:00
parent 99007ffc89
commit dc1e06ac67
16 changed files with 159 additions and 27 deletions
@@ -34,10 +34,32 @@
// Aufgabe
const firstName = prompt('Wilkommen. Wie heißen Sie mit Vornamen?');
const lastName = prompt('Und mit Nachnamen?');
const age = Number(prompt('Wie alt sind Sie?'));
const favoriteHotDrink = prompt('Und was ist ihr liebstes Heißgetränk? tee (t) oder kaffee (c)?');
const age = Number('Wie alt sind Sie?');
let errorMessage = '';
const favoriteHotDrink = prompt('Und was ist ihr liebstes Heißgetränk? (tee | kaffee)');
if (lastName.length < 2 || lastName.length > 100) {
errorMessage += 'name ';
}
if (firstName.length < 2 || firstName.length > 100) {
errorMessage += 'first name ';
}
if (favoriteHotDrink !== 'c' && favoriteHotDrink !== 't') {
errorMessage += 'favoriteHotDrink ';
}
if (isNaN(age) || age >= 150) {
errorMessage += 'age ';
}
if (errorMessage === '') {
console.log('OK!');
} else {
console.log(`KO! The following entries are invalid: ${errorMessage}`);
}
</script>
</body>
</html>