krokodille
This commit is contained in:
parent
014d16d138
commit
7b19e5860c
|
@ -8,12 +8,16 @@
|
||||||
img{
|
img{
|
||||||
height: 100px;
|
height: 100px;
|
||||||
}
|
}
|
||||||
|
div{
|
||||||
|
background-color: gray;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div>
|
<div>
|
||||||
Poeng: <div id="points"></div>
|
Poeng: <div id="points"></div>
|
||||||
<img src="../../Crocodile.svg.png">
|
<img src="../../Crocodile.svg.png">
|
||||||
|
<div>Lovlige operatorer < og > og = og ==</div>
|
||||||
<div id="number1">
|
<div id="number1">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -28,26 +32,27 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
let points = 0;
|
let points = 0;
|
||||||
|
var number1
|
||||||
|
var number2
|
||||||
document.getElementById('points').innerHTML = `${points}`;
|
document.getElementById('points').innerHTML = `${points}`;
|
||||||
function randomNumber(){
|
function randomNumber(){
|
||||||
number1 = Math.floor(Math.random() * 10) + 1;
|
number1 = Math.floor(Math.random() * 10) + 1;
|
||||||
number2 = Math.floor(Math.random() * 10) + 1;
|
number2 = Math.floor(Math.random() * 10) + 1;
|
||||||
document.getElementById('number1').innerHTML = `${number1}`;
|
document.getElementById('number1').innerHTML = `${number1}`;
|
||||||
document.getElementById('number2').innerHTML = `${number2}`;
|
document.getElementById('number2').innerHTML = `${number2}`;
|
||||||
return number1, number2
|
|
||||||
|
|
||||||
}
|
}
|
||||||
function check(number1, number2){
|
function check(){
|
||||||
let operator = document.getElementById("operator").value;
|
let operator = document.getElementById("operator").value;
|
||||||
if ((number1 + operator + number2) == true){
|
// console.log(eval(number1 + operator + number2))
|
||||||
|
if (operator = '='){
|
||||||
|
operator = '==';
|
||||||
|
}
|
||||||
|
if (eval(number1 + operator + number2)){
|
||||||
++points;
|
++points;
|
||||||
document.getElementById('points').innerHTML = `${points}`;
|
document.getElementById('points').innerHTML = `${points}`;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
alert('Wrong!');
|
alert('It is Wrong! to use Alert');
|
||||||
}
|
}
|
||||||
console.log(operator)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in a new issue