From c6dabbbc32efda9e47224445d0828a7a0830f504 Mon Sep 17 00:00:00 2001 From: Emily Garvey <41160828+emilygarvey@users.noreply.github.com> Date: Thu, 27 May 2021 16:08:54 -0400 Subject: [PATCH] starter code --- README.md | 6 +++--- js/script.js | 53 ---------------------------------------------------- 2 files changed, 3 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index b496852e..60492045 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,9 @@ In this unit, coders will create a Rock, Paper, Scissors game. The Rock, Paper, #### GitHub Set-Up - [x] Go to the repository at https://github.com/itscodenation/rockpaperscissors -- [x] Fork this repository to your Github account and import to a new workspace -- [x] Link and commit your changes -- [x] Make your site live on GitHub Pages +- [ ] Fork this repository to your Github account and import to a new workspace +- [ ] Link and commit your changes +- [ ] Make your site live on GitHub Pages #### Code Walkthrough diff --git a/js/script.js b/js/script.js index 660b1cb8..e69de29b 100644 --- a/js/script.js +++ b/js/script.js @@ -1,53 +0,0 @@ -//Click Function when play is clicked -$(".play").click(function () { - //Takes in User Choice from the input box and stores it in a variable - let userChoice = $(".input").val(); - - //Display the user choice to the screen - $(".userChoice").html(userChoice); - - //Display the computer choice to the screen - let computerChoice = getRandomComputerChoice(); - $(".computerChoice").html(computerChoice); - - //Displays the winner choice to the screen - let winner = chooseWinner(userChoice, computerChoice); - $(".result").html(winner); - - // Clears the input box - $(".input").val(""); -}); - -function getRandomComputerChoice() { - let randomNumber = Math.random(); - let computerChoice; - - if (randomNumber < 0.33) { - computerChoice = "rock"; - } else if (randomNumber < 0.67) { - computerChoice = "paper"; - } else { - computerChoice = "scissors"; - } - return computerChoice; -} - -function chooseWinner(userChoice, computerChoice) { - let winner; - if ( - (userChoice === "rock" && computerChoice === "paper") || - (userChoice === "paper" && computerChoice === "scissors") || - (userChoice === "scissors" && computerChoice === "rock") - ) { - winner = "Computer Wins!"; - } else if ( - (userChoice === "rock" && computerChoice === "scissors") || - (userChoice === "paper" && computerChoice === "rock") || - (userChoice === "scissors" && computerChoice === "paper") - ) { - winner = "User Wins!"; - } else { - winner = "No one Wins!"; - } - return winner; -}