diff --git "a/Sorteio N\303\272mero Randomico/index.html" "b/Sorteio N\303\272mero Randomico/index.html" new file mode 100644 index 0000000..76f913e --- /dev/null +++ "b/Sorteio N\303\272mero Randomico/index.html" @@ -0,0 +1,26 @@ + + + + + + + + Exer11 - Aula 6 + + + + +
+ + Chute:
+
+ Dica:
+ +
+ +
+ + + + + \ No newline at end of file diff --git "a/Sorteio N\303\272mero Randomico/script/script.js" "b/Sorteio N\303\272mero Randomico/script/script.js" new file mode 100644 index 0000000..728fc68 --- /dev/null +++ "b/Sorteio N\303\272mero Randomico/script/script.js" @@ -0,0 +1,32 @@ +window.onload = function () { + + var num_secreto; + var tentativas = 0; + var div_msg = document.getElementById("msg"); + var campo_dica = document.getElementById("txtdica"); + + num_secreto = sortearNumero(); + + document.getElementById("botao").onclick = function(){ + + tentativas++; + var num_chute = parseInt(document.getElementById("txtchute").value); + + if (num_chute < num_secreto) { + campo_dica.value = "O número sorteado é maior."; + } + + else if (num_chute > num_secreto) { + campo_dica.value = "O número sorteado é menor."; + } + + else { + div_msg.innerHTML = "

Parabéns. Você acertou em " + + tentativas + " tentativas

" + "

Pressione F5 para jogar novamente

"; + } + } +} + +function sortearNumero(){ + return Math.round(Math.random() * 100); +} \ No newline at end of file