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

Added function that compares number to 10

parent 371b8c80
......@@ -50,7 +50,6 @@
let beskjed = await showOff(telefon);
utdata.innerHTML += "<br>" + beskjed;
}
catch (error) {
// ajaj, mamma kjøpte ikke telefon
......@@ -59,8 +58,33 @@
utdata.innerHTML += "<br>Etter jeg har spurt mamma";
}
// Ny kode
async function tallOver10(tall) {
return new Promise(
(resolve, reject) => {
console.log(2, tall);
if (tall > 10) {
resolve("Tallet er over 10");
}
if (tall < 10) {
resolve("Tallet er under 10");
}
resolve("Tallet er 10");
}
)
}
async function testTall(tall) {
svar = await tallOver10(tall);
utdata.innerHTML += "<br>" + svar;
}
// Kode som kjører funksjonene
(async () => {
await hvaSierMamma();
utdata.innerHTML += "<br>"
await testTall(2);
await testTall(15);
await testTall(10);
})();
</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