Este artigo descreve o jogo de adivinhação de número implementado por JavaScript. Compartilhe -o para sua referência, como segue:
<! xmlns = "http://www.w3.org/1999/xhtml"> <head> <meta http-equiv = "content-type" content = "text/html; charset = utf-8"/> js jogo </title> <script; //x=Parseint(math.random( )*(1000-1))+1; for (var i = 0; i <10; i ++) {var num = prompt ("Por favor, digite o número que você adivinhou", ""); if (num! = null && num! = "") {if (num == x) {switch (i) {case 0: alert ('é tão divino, adivinhe certo!'); i = 10; quebrar; caso 1: alerta ('incrível, sim!'); i = 10; quebrar; Caso 2: Alert ('Bom, sim!'); i = 10; quebrar; Caso 3: Alert ('Ok, sim!'); i = 10; quebrar; Caso 3: Alert ('Ok, sim!'); i = 10; quebrar; Caso 4: Alert ('Não é fácil, certo!'); i = 10; quebrar; Caso 5: Alert ('vai se estabelecer, certo!'); i = 10; quebrar; Caso 6: Alert ('É um pouco lento, certo!'); i = 10; quebrar; Caso 7: Alert ('Apresse -se da próxima vez, certo!'); i = 10; quebrar; Caso 8: Alert ('Pegue, certo!'); i = 10; quebrar; Caso 9: Alert ('Última chance, certo!'); i = 10; quebrar; }} if (i == 9) {alert ('idiota, adivinhei 10 vezes!'); } if (num> x) {document.write ("Você adivinhou" + avaliar (i + 1) + "vezes" + num + "," + "big! <br>"); } if (num <x) {document.write ("Você adivinhou" + avaliar (i + 1) + "vezes" + num + "," + "pequeno! <br>"); }} else {alert ('não pode estar vazio'); }} </script> </ad Head> <body> <div id = "div1"> </div> </body> </html>For more information about JavaScript related content, please check out the topics of this site: "Summary of JavaScript switching effects and techniques", "Summary of JavaScript search algorithm skills", "Summary of JavaScript animation effects and techniques", "Summary of JavaScript errors and debugging techniques", "Summary of JavaScript data structures and algorithm skills", "Summary of Javascript Algoritmos e Técnicas de Traversal "e" Resumo do Uso do Javascript Mathematic Operations "
Espero que este artigo seja útil para a programação JavaScript de todos.