Created
April 16, 2020 10:56
-
-
Save johannesegger/3ad7f4bad8483f66090e5093479d8117 to your computer and use it in GitHub Desktop.
Wort buchstabieren
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let alphabet = { | |
"A": "Anton", | |
"B": "Berta", | |
"C": "Cäsar", | |
"D": "Dora", | |
"E": "Emil", | |
"F": "Friedrich", | |
"G": "Gustav", | |
"H": "Heinrich", | |
"I": "Ida", | |
"J": "Julius", | |
"K": "Konrad", | |
"L": "Ludwig", | |
"M": "Martha", | |
"N": "Nordpol", | |
"O": "Otto", | |
"P": "Paula", | |
"Q": "Quelle", | |
"R": "Richard", | |
"S": "Siegfried", | |
"T": "Theodor", | |
"U": "Ulrich", | |
"V": "Viktor", | |
"W": "Wilhelm", | |
"X": "Xaver", | |
"Y": "Ypsilon", | |
"Z": "Zürich", | |
"0": "Null", | |
"1": "Eins", | |
"2": "Zwei", | |
"3": "Drei", | |
"4": "Vier", | |
"5": "Fünf", | |
"6": "Sechs", | |
"7": "Sieben", | |
"8": "Acht", | |
"9": "Neun" | |
} | |
let text = window.prompt("Text eingeben") | |
let spelling = [] | |
for (let i = 0; i < text.length; i++) { | |
let c = text.charAt(i) | |
let word = alphabet[c.toUpperCase()] || c | |
let size = "" | |
if (c >= 'a' && c <= 'z') size = "kleines " | |
if (c >= 'A' && c <= 'Z') size = "großes " | |
spelling.push(`${size}${word}`) | |
} | |
let result = spelling.join(", ") | |
function writeToClipboard() { | |
navigator.clipboard.writeText(result) | |
alert("Ergebnis ist in der Zwischenablage") | |
window.removeEventListener("focus", writeToClipboard) | |
} | |
window.addEventListener("focus", writeToClipboard) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment