Skip to content

Commit

Permalink
starter code
Browse files Browse the repository at this point in the history
  • Loading branch information
emilygarvey committed May 27, 2021
1 parent 8b26f7e commit c6dabbb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 56 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
53 changes: 0 additions & 53 deletions js/script.js
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit c6dabbb

Please sign in to comment.