19 lines
454 B
JavaScript
19 lines
454 B
JavaScript
function analyseText(text) {
|
|
if (text === null || !text.trim()) {
|
|
return "Fehler: Der Text darf nicht leer sein!";
|
|
}
|
|
|
|
const zeichen = text.length;
|
|
const woerter = text.split(" ").filter(w => w.trim() !== "").length;
|
|
const gross = text.toUpperCase();
|
|
|
|
return `Analyse-Ergebnis:
|
|
Zeichen: ${zeichen}
|
|
Wörter: ${woerter}
|
|
Großbuchstaben: ${gross}`;
|
|
}
|
|
|
|
const eingabe = prompt("Bitte gib einen Text ein:");
|
|
alert(analyseText(eingabe));
|
|
|
|
|