Skip to content

Instantly share code, notes, and snippets.

@carlosmoretti
Created September 10, 2021 12:27
Show Gist options
  • Select an option

  • Save carlosmoretti/26a728413bc815538d9495c315be8264 to your computer and use it in GitHub Desktop.

Select an option

Save carlosmoretti/26a728413bc815538d9495c315be8264 to your computer and use it in GitHub Desktop.
const icones = [{
icon: "✊",
beat: "✌️"
}, {
icon: "🖐",
beat: "✊"
}, {
icon: "✌️",
beat: "🖐"
}]
const sortear = () => {
setMensagem("Jo, ken, po...")
setIconeIA(null);
let iconUsuario = icones.find(e => e.icon == icone);
let iconIA = icones.map(e => e.icon)[Math.floor(Math.random() * (3 - 0))];
setIconeIA(iconIA);
if(iconIA == iconUsuario.beat)
setMensagem("Você venceu!");
else if(iconIA == iconUsuario.icon)
setMensagem("Empate!");
else
setMensagem("Você perdeu");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment