27 lines
No EOL
610 B
JavaScript
27 lines
No EOL
610 B
JavaScript
window.analyseText = function (text) {
|
|
const sauberesText = text.trim();
|
|
|
|
const zeichen = sauberesText.length;
|
|
const wörter = sauberesText.split(/\s+/).filter(Boolean).length;
|
|
const upper = sauberesText.toUpperCase();
|
|
|
|
return `
|
|
Zeichen: ${zeichen}
|
|
Wörter: ${wörter}
|
|
Großbuchstaben: ${upper}
|
|
`;
|
|
};
|
|
|
|
window.startAnalyse = function () {
|
|
const text = prompt("Gib einen Text ein:");
|
|
|
|
if (typeof text !== "string" || text.trim() === "") {
|
|
alert("Fehler: Kein gültiger Text eingegeben!");
|
|
return;
|
|
}
|
|
|
|
const result = window.analyseText(text);
|
|
|
|
console.log(result);
|
|
alert(result);
|
|
}; |