Toda vez que faço uma tentativa e aperto o botão chutar o numero não é limpo.
Código abaixo:
let numeroSecreto = gerarNumeroAleatorio();
console.log(numeroSecreto);
let tentativas = 1;
function exibirTextoNaTela(tag, texto) {
let campo = document.querySelector(tag);
campo.innerHTML = texto;
}
function mensagemInicial(){
exibirTextoNaTela('h1', 'Jogo do numero');
exibirTextoNaTela('p', 'Escolha entre 1 a 10');
}
function verificarChute() {
let chute = parseInt(document.querySelector('input').value);
if (chute == numeroSecreto){
exibirTextoNaTela('h1', 'ACERTOUUUU!!!!!!!!');
let palavraTentativa = tentativas > 1 ? 'tentativas':'tentativa'
let mensagemTentativa = `Voce acertou o numero secreto com ${tentativas} ${palavraTentativa}`
exibirTextoNaTela('p',mensagemTentativa );
document.getElementById('reiniciar').removeAttribute('disabled');
} else if (chute > numeroSecreto){
exibirTextoNaTela('p', 'Numero secreto é menor');
} else{
exibirTextoNaTela('p', 'numero secreto é maior');
}
tentativas++
}
function gerarNumeroAleatorio() {
return parseInt(Math.random() * 10 + 1 );
}
function limparCampo() {
chute = document.querySelector('input');
chute.value = ' ';
}
function reiniciarJogo(){
numeroSecreto = gerarNumeroAleatorio();
limparCampo();
tentativas = 1;
mensagemInicial();
document.getElementById('reiniciar').setAttribute('disebled', true)
}