Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created September 10, 2020 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/a2bda3ff386cc5360a968e1b0c0170f1 to your computer and use it in GitHub Desktop.
Save codecademydev/a2bda3ff386cc5360a968e1b0c0170f1 to your computer and use it in GitHub Desktop.
Codecademy export
/*
const getUserChoice = userInput => {
userInput = userInput.toLowerCase();
if (userInput === 'paper' || userInput === 'rock' || userInput === 'scissors') {
return userInput;
} else {
console.log("enter correct statment!");
}
}
const getCompChoice = () => {
const numb = Math.floor(Math.random()*3);
switch(numb) {
case 0:
return 'paper';
break;
case 1:
return 'scissors';
break;
case 2:
return 'rock';
break;
}
}
*/
const determineWinner = (userChoice, compChoice) => {
if (userChoice === 'compChoice') {return 'Tie!';}
if (userChoice === 'rock') {
if (compChoice === 'paper') {return 'Computer wins';} } else {return 'You Win!';}
if (userChoice === 'paper') {
if(compChoice === 'scissors') {return 'Computer wins';}
} else {return 'You Win!';}
if (userChoice === 'scissors') {
if (compChoice === 'rock') {return 'Computer wins';}
} else {return 'You Win!';}
}
console.log(determineWinner('paper', 'scissors'));
//console.log(determineWinner(scissors, paper));
//console.log(determineWinner(paper, paper));
/*
const playGame = () => {
let userChoice = getUserChoice('paper');
let compChoice = getCompChoice();
console.log(`Comp has choosen ${compChoice} and you have picked ${userChoice}!`);
console.log(determineWinner(userChoice, compChoice));
}
playGame();
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment