<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Secreto</title>
<h1>SECRETO</h1>
</head>
<body>
<input placeholder="Digite numero aqui" />
<button>Comprobar número secreto</button>
<script>
var secretNumber = [3, 4, 5, 7],
input1 = document.querySelector("input");
input1.focus();
function verificar() {
encontrado = false;
for (let position = 0; position < 4; position++) {
if (parseInt(input1.value) == secretNumber[position]) {
alert("Es correcto");
encontrado = true;
break;
};
};
input1.value = "";
input1.focus();
if (encontrado == false) {
alert("Incorreto");
};
};
let button = document.querySelector("button");
button.onclick = verificar;
</script>
</body>
</html>