a couple of loops
This commit is contained in:
parent
12dc3057b6
commit
5868ff1a7a
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>
|
||||
<div id="text">Tekst her</div>
|
||||
<button onclick="change()">Trykk her</button>
|
||||
Vis dyr: <input id="showAnimal" onchange="show()"></button>
|
||||
<div id="show"></div>
|
||||
</div>
|
||||
<script>
|
||||
function change() {
|
||||
let animalList = ["hund", "katt", "esel"];
|
||||
let animal = animalList[Math.floor(Math.random() * animalList.length)];
|
||||
document.getElementById('text').innerHTML = `${animal}`;
|
||||
}
|
||||
function show(){
|
||||
let animal = document.getElementById('showAnimal').value;
|
||||
document.getElementById('show').innerHTML = `${animal}`;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
5
eloquentjavascript/loops.js
Normal file
5
eloquentjavascript/loops.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
for (let i = 0; i <= 9; i++){
|
||||
if (i % 2 !== 0) console.log(i);
|
||||
}
|
||||
let i = 0;
|
||||
while (i < 10) { console.log(i); i++; }
|
Loading…
Reference in a new issue