lyspære conditionals
This commit is contained in:
parent
49cf225a2e
commit
9929d0349f
31
intro_js/clicker.html
Normal file
31
intro_js/clicker.html
Normal file
|
@ -0,0 +1,31 @@
|
|||
<!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>
|
||||
Poeng <span id="points"></span><br>
|
||||
<button onclick="addPoints()">Klikk her</button>
|
||||
<button onclick="upgrade()">Oppgrader</button>
|
||||
<button onclick="reset()">Reset</button>
|
||||
<script>
|
||||
let points = 0;
|
||||
let upgrades = 1;
|
||||
function addPoints(){
|
||||
points += upgrades;
|
||||
document.getElementById('points').innerHTML = points;
|
||||
};
|
||||
function upgrade(){
|
||||
upgrades++;
|
||||
points -= 10;
|
||||
document.getElementById('points').innerHTML = points;
|
||||
}
|
||||
function reset(){
|
||||
points = 0;
|
||||
upgrades = 1;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
43
intro_js/kjøpe_øl.html
Normal file
43
intro_js/kjøpe_øl.html
Normal file
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Mannen var ute etter øl</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>
|
||||
Alder: <br>
|
||||
<input id="age" onchange="checkIfCanBuyBeer()">
|
||||
Ser ut som alder: <br>
|
||||
<input id="looksAge" onchange="checkIfCanBuyBeer()" type="slider">
|
||||
Har id:
|
||||
<input id="hasId" onchange="checkIfCanBuyBeer()" type="checkbox">
|
||||
</div>
|
||||
<div id="info">
|
||||
|
||||
</div>
|
||||
<script>
|
||||
|
||||
|
||||
checkIfCanBuyBeer();
|
||||
function checkIfCanBuyBeer() {
|
||||
let age = document.getElementById('age').valueAsNumber;
|
||||
let looksAge = document.getElementById('looksAge').valueAsNumber;
|
||||
let hasId = document.getElementById('hasId').checked;
|
||||
let canBuyBeer = false;
|
||||
|
||||
if (looksAge >= 25) {
|
||||
|
||||
} else {
|
||||
if (hasId){}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in a new issue