<meta charset="UTF-8">
<input/>
<button>segredo</button>
<script>
var adivinha = Math.round(Math.random() *5);
var input = document.querySelector("input");
function manda(){
if(input.value==adivinha){
document.write("<br><br>vc acertou");
}else{
document.write("<br><br>vc errou");
}
input.value = "";
input.focus();
}
var button = document.querySelector("button");
button.onclick=manda;
</script>