Skip to content

Commit

Permalink
sustitucion de variables ENUM
Browse files Browse the repository at this point in the history
  • Loading branch information
emervzla committed Nov 16, 2023
1 parent 6957960 commit 1e1c83a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ const machineScore = document.querySelector("#machine-score")
let humanScoreNumber = 0
let machineScoreNumber = 0

const GAME_OPTIONS = {
ROCK: "rock",
PAPER: "paper",
SCISSORS: "scissors"
}

const playHuman = (humanChoise) => {
playTheGame (humanChoise, playMachine())
}

const playMachine = () => {
const choises = ["rock", "paper", "scissors"]
const choises = [GAME_OPTIONS.ROCK, GAME_OPTIONS.PAPER, GAME_OPTIONS.SCISSORS]
const randomNumber = Math.floor(Math.random() * 3)

return choises[randomNumber]
Expand All @@ -23,9 +29,9 @@ const playTheGame = (human, machine) => {
result.innerHTML = "Deu empate!"
}

else if ((human === "paper" && machine === "rock") ||
(human === "rock" && machine === "scissors") ||
(human === "scissors" && machine === "paper")) {
else if ((human === GAME_OPTIONS.PAPER && machine === GAME_OPTIONS.ROCK) ||
(human === GAME_OPTIONS.ROCK && machine === GAME_OPTIONS.SCISSORS) ||
(human === GAME_OPTIONS.SCISSORS && machine === GAME_OPTIONS.PAPER)) {

humanScoreNumber++
humanScore.innerHTML = humanScoreNumber
Expand Down

0 comments on commit 1e1c83a

Please sign in to comment.