let numeroSecreto = gerarNumeroAleatorio();
function exibirTextoNaTela(tag, texto){
let campo = document.querySelector (tag);
campo.innerHTML = texto;
}
exibirTextoNaTela ('h1','jogo go numero secreto');
exibirTextoNaTela ('p','escolha um numero entre 1 e 10');
function verificarChute() {
console.log (numeroSecreto);
}
function gerarNumeroAleatorio() {
return panseInt (Math.ramdom()* 10 + 1);
Erro que aparece no console:
app.js:12 Uncaught ReferenceError: Cannot access 'numeroSecreto' before initialization
at verificarChute (app.js:12:18)
at HTMLButtonElement.onclick (index.html:27:81)
index.HTML :
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://code.responsivevoice.org/responsivevoice.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@700&family=Inter:wght@400;700&display=swap"
rel="stylesheet">
<link rel="stylesheet" href="style.css">
<title>JS Game</title>
</head>
<body>
<div class="container">
<div class="container__conteudo">
<div class="container__informacoes">
<div class="container__texto">
<h1></h1>
<p class="texto__paragrafo"></p>
</div>
<input type="number" min="1" max="10" class="container__input">
<div class="chute container__botoes">
<button onclick="verificarChute()" class="container__botao">Chute</button>
<button onclick="" id="reiniciar" class="container__botao" disabled>Novo jogo</button>
</div>
</div>
<img src="./img/ia.png" alt="Uma pessoa olhando para a esquerda" class="container__imagem-pessoa" />
</div>
</div>
<script src="app.js" defer></script>
</body>
</html>