2024-08-23 13:28:42 +02:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
2024-08-23 13:46:21 +02:00
|
|
|
|
2024-08-23 13:28:42 +02:00
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title>Krokodille</title>
|
|
|
|
<style>
|
2024-08-23 13:46:21 +02:00
|
|
|
img {
|
2024-08-23 13:28:42 +02:00
|
|
|
height: 100px;
|
|
|
|
}
|
2024-08-23 13:46:21 +02:00
|
|
|
|
|
|
|
div {
|
2024-08-23 13:34:50 +02:00
|
|
|
background-color: gray;
|
|
|
|
}
|
2024-08-23 13:28:42 +02:00
|
|
|
</style>
|
|
|
|
</head>
|
2024-08-23 13:46:21 +02:00
|
|
|
|
2024-08-23 13:28:42 +02:00
|
|
|
<body>
|
|
|
|
<div>
|
|
|
|
Poeng: <div id="points"></div>
|
|
|
|
<img src="../../Crocodile.svg.png">
|
2024-08-23 13:46:21 +02:00
|
|
|
<div>Lovlige operatorer '<' og '>' og '=' og '==' </div>
|
|
|
|
<div id="number1">
|
2024-08-23 13:28:42 +02:00
|
|
|
|
2024-08-23 13:46:21 +02:00
|
|
|
</div>
|
|
|
|
<input id="operator">
|
|
|
|
<div id="number2">
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<button onclick="check()">Submit</button>
|
|
|
|
<button onclick="randomNumber()">Reset</button>
|
|
|
|
</div>
|
2024-08-23 13:28:42 +02:00
|
|
|
</div>
|
|
|
|
|
2024-08-23 13:46:21 +02:00
|
|
|
<script>
|
|
|
|
let points = 0;
|
|
|
|
var number1
|
|
|
|
var number2
|
|
|
|
document.getElementById('points').innerHTML = `${points}`;
|
|
|
|
function randomNumber() {
|
|
|
|
number1 = Math.floor(Math.random() * 10) + 1;
|
|
|
|
number2 = Math.floor(Math.random() * 10) + 1;
|
|
|
|
document.getElementById('number1').innerHTML = `${number1}`;
|
|
|
|
document.getElementById('number2').innerHTML = `${number2}`;
|
2024-08-23 13:28:42 +02:00
|
|
|
}
|
2024-08-23 13:46:21 +02:00
|
|
|
function check() {
|
|
|
|
let operator = document.getElementById("operator").value;
|
|
|
|
console.log(operator)
|
|
|
|
if (operator == '=') {
|
|
|
|
operator == '==';
|
|
|
|
}
|
|
|
|
console.log(eval(number1 + operator + number2));
|
|
|
|
if (eval(number1 + operator + number2)) {
|
|
|
|
++points;
|
|
|
|
document.getElementById('points').innerHTML = `${points}`;
|
|
|
|
} else {
|
|
|
|
alert('It is Wrong! to use Alert');
|
|
|
|
console.log(operator)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
2024-08-23 13:28:42 +02:00
|
|
|
</body>
|
2024-08-23 13:46:21 +02:00
|
|
|
|
2024-08-23 13:28:42 +02:00
|
|
|
</html>
|