startit/intro_js/clicker.html

36 lines
911 B
HTML
Raw Normal View History

2024-08-22 14:28:11 +02:00
<!DOCTYPE html>
<html lang="en">
2024-08-23 10:18:23 +02:00
2024-08-22 14:28:11 +02:00
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=<device-width>, initial-scale=1.0">
<title>Document</title>
</head>
2024-08-23 10:18:23 +02:00
2024-08-22 14:28:11 +02:00
<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;
2024-08-23 10:18:23 +02:00
function addPoints() {
2024-08-22 14:28:11 +02:00
points += upgrades;
document.getElementById('points').innerHTML = points;
};
2024-08-23 10:18:23 +02:00
function upgrade() {
if (points >= 10) {
upgrades++;
points -= 10;
document.getElementById('points').innerHTML = points;
}
2024-08-22 14:28:11 +02:00
}
2024-08-23 10:18:23 +02:00
function reset() {
2024-08-22 14:28:11 +02:00
points = 0;
upgrades = 1;
}
</script>
</body>
2024-08-23 10:18:23 +02:00
2024-08-22 14:28:11 +02:00
</html>