Skip to content

Instantly share code, notes, and snippets.

@allanaguilar
Created June 28, 2015 02:37
Show Gist options
  • Save allanaguilar/96b37a4fdd1db6fc6ccd to your computer and use it in GitHub Desktop.
Save allanaguilar/96b37a4fdd1db6fc6ccd to your computer and use it in GitHub Desktop.
//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