diff --git a/script.js b/script.js index b7c69b9..84f0d32 100644 --- a/script.js +++ b/script.js @@ -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] @@ -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