Commit f96e5bd8 authored by Sander Kvenild's avatar Sander Kvenild
Browse files

Made a function to uppercase an array of words

parent f58a799e
......@@ -78,13 +78,32 @@
utdata.innerHTML += "<br>" + svar;
}
async function lagStoreBokstaver(stringArray) {
return new Promise(
(resolve, reject) => {
for (i = 0; i < stringArray.length; i++) {
if (/[^a-zA-ZæøåÆØÅ]/.test(stringArray[i])) {
var reason = new Error(`Element: ${i} inneholder symboler som ikke er bokstaver!`);
reject(reason);
return;
}
}
stringArray = stringArray.map((e) => e.toUpperCase())
resolve(`[${stringArray.join(", ")}]`);
}
)
}
// Kode som kjører funksjonene
(async () => {
await hvaSierMamma();
utdata.innerHTML += "<br>"
utdata.innerHTML += "<br>";
await testTall(2);
await testTall(15);
await testTall(10);
utdata.innerHTML += "<br>";
let temp = await lagStoreBokstaver(["abcdefg", "sander", ""]);
utdata.innerHTML += "<br>" + temp;
})();
</script>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment