"use strict"
let t1, t2, t3, a, b, c, res, ttt, n, timer, t4, d,v,v1,s,s1,x,x1,c1,c2,c3,c4,a1,b1,r
window.onload = function() {
t1 = document.getElementById("t1");
t2 = document.getElementById("t2");
t3 = document.getElementById("t3");
t4 = document.getElementById("t4");
res = document.getElementById("res");
ttt = document.getElementById("ttt");
v = document.getElementById("v");
s = document.getElementById("s");
x = document.getElementById("x");
function getRandomInRange(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
c1 = 0
v1 = parseInt(v.value);
v1 = 0
v.innerHTML = v1
x1 = parseInt(v.value);
x1 = 0
if (confirm("режим с умножением")) {
x1 = getRandomInRange(1,3)
c1 = 1
} else {
x1 = getRandomInRange(1,2)
c1 = 2
}
if (confirm("режим до тысячи")) {
a = parseInt(t1.value);
b = parseInt(t2.value);
a = getRandomInRange(1, 1000)
b = getRandomInRange(1, 1000)
t1.innerHTML = a
t2.innerHTML = b
r = 1
} else {
a = parseInt(t1.value);
b = parseInt(t2.value);
a = getRandomInRange(1, 100)
b = getRandomInRange(1, 100)
t1.innerHTML = a
t2.innerHTML = b
r = 2
}
if (x1 == 1 && c1 == 1) {
c = a + b
x.innerHTML = "+"
}
if ((x1 == 2) && (c1 == 1)) {
c = a - b
x.innerHTML = "-"
}
if ((x1 == 3) && (c1 == 1)) {
c = a * b
x.innerHTML = "*"
}
if ((x1 == 1) && (c1 == 2)) {
c = a + b;
x.innerHTML = "+"
}
if ((x1 == 2) && (c1 == 2)) {
c = a - b
x.innerHTML = "-"
}
t3.onclick = function() {
d = parseInt(t4.value)
if(c === d) {
if ((r = 1) && (c1 = 1)) {
v1 = v1 + 1
v.innerHTML = v1
a = parseInt(t1.value);
b = parseInt(t2.value);
a = getRandomInRange(1, 1000)
b = getRandomInRange(1, 1000)
t1.innerHTML = a
t2.innerHTML = b
n = 0
x1 = getRandomInRange(1,3)
}
if ((r = 2) (c1 = 1)) {
x1 = getRandomInRange(1,3)
v1 = v1 + 1
v.innerHTML = v1
a = parseInt(t1.value);
b = parseInt(t2.value);
a = getRandomInRange(1, 100)
b = getRandomInRange(1, 100)
t1.innerHTML = a
t2.innerHTML = b
n = 0
}
if ((r = 1) && (c1 = 2)) {
v1 = v1 + 1
v.innerHTML = v1
a = parseInt(t1.value);
b = parseInt(t2.value);
a = getRandomInRange(1, 1000)
b = getRandomInRange(1, 1000)
t1.innerHTML = a
t2.innerHTML = b
n = 0
x1 = getRandomInRange(1,2)
}
if ((r = 2) (c1 = 2)) {
x1 = getRandomInRange(1,2)
v1 = v1 + 1
v.innerHTML = v1
a = parseInt(t1.value);
b = parseInt(t2.value);
a = getRandomInRange(1, 100)
b = getRandomInRange(1, 100)
t1.innerHTML = a
t2.innerHTML = b
n = 0
}
} else {
alert( "Ваш счет : " + v1 )
}
}
n = 0
timer = setInterval(function() {
n = n + 1
ttt.innerHTML = n
if (x1 != 3) {
if (n >= 10) {
alert( "Ваш счет : " + v1 )
}
}
if (x1 = 3) {
if (n >= 15) {
alert( "Ваш счет : " + v1 )
}
}
if(r = 1) {
if ((a > 100)&&(b > 100)) {
if (n >= 15) {
alert( "Ваш счет : " + v1 )
}
}
}
}, 1000);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h2>Очки:</h2>
<h2 id = "v"></h2>
<span>Число А</span>
<br>
<h2 id = "t1"></h2>
<br>
<span>Знак</span>
<br>
<h2 id = "x"></h2>
<br>
<span>Число Б</span>
<br>
<h2 id = "t2"></h2>
<br>
<input type="text" id = "t4">
<button id = "t3">Ответ</button>
<br>
<alert id = "s">asd</alert>
<h2 id = ttt>0</h2>
<script src = "code.js"></script>
</body>
</html>