Created
June 28, 2015 02:37
-
-
Save allanaguilar/96b37a4fdd1db6fc6ccd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Genera un número aleatorio entre un rango de enteros | |
function patito(minimo, maximo) | |
{ | |
var numero = Math.floor( Math.random() * (maximo - minimo + 1) + minimo ); | |
return numero; | |
} | |
var opciones = ["Piedra", "Papel", "Tijera","Lagarto", "Spock"]; | |
var opcionUsuario; | |
var opcionMaquina = patito(0,4); | |
var resultados = [ ["Empate!", "Perdise :(", "Ganaste!", "Ganaste!", "Perdiste :("], | |
["Ganaste!", "Empate ", "Perdise!", "Perdise", "Ganaste!"], | |
["Perdise!", "Ganaste :)", "Empate!", "Ganaste!", "Perdise :("], | |
["Perdise", "Ganaste", "Perdise", "Empate", "Ganaste"], | |
["Ganaste", "Perdise", "Ganaste", "Perdise", "Empate"]]; | |
opcionUsuario = prompt("¿Qué eliges?\nPiedra: 0\nPapel: 1\nTijera: 2\nLagarto: 3\nSpock: 4", 0); | |
window.alert("My name is George. Welcome!") | |
alert("Elegiste " + opciones[opcionUsuario]); | |
alert("Javascript eligió " + opciones[opcionMaquina]); | |
alert(resultados[opcionUsuario][opcionMaquina]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment