Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<html>
<head>
</head>
<body>
<script>
var palpite;
var tentativas = 0;
var num;
var confirmar;
num = Math.round(Math.random() * 100);
console.log(num)
function pergunta() {
palpite = parseInt(prompt("digite"));
tentativas++;
if (palpite < num) {
alert("menor")
} else if(palpite == num) {
alert("igual")
} else {
alert("maior")
}
if (palpite == num) {
alert("parabens, voce fez " + tentativas + " antes de acertar")
repetir()
} else {
pergunta()
}
}
function repetir() {
confirmar = confirm("Voce quer continuar")
if (confirmar) {
pergunta()
}
}
pergunta()
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.