Last active
September 24, 2015 21:48
-
-
Save MicFin/1457e81a28ef81079979 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// long comprison of each scenario | |
if (computerSelection === "rock" && userSelection == "scissors") { | |
console.log("Computer Wins"); | |
} else if (computerSelection === "paper" && userSelection == "rock") { | |
console.log("Computer Wins"); | |
} else if (computerSelection === "scissors" && userSelection == "paper") { | |
console.log("Computer Wins"); | |
} else if (computerSelection === "scissors" && userSelection == "rock") { | |
console.log("User Wins"); | |
} else if (computerSelection === "paper" && userSelection == "scissors") { | |
console.log("User Wins"); | |
} else if (computerSelection === "rock" && userSelection == "paper") { | |
console.log("User Wins") | |
}else { | |
console.log("Tie"); | |
} | |
// if else with less logic | |
if (computerSelection === userSelection ) { | |
console.log("Tie"); | |
} else if (computerSelection === "rock" && userSelection == "scissors") { | |
console.log("Computer Wins"); | |
} else if (computerSelection === "paper" && userSelection == "rock") { | |
console.log("Computer Wins"); | |
} else if (computerSelection === "scissors" && userSelection == "paper") { | |
console.log("Computer Wins"); | |
}else { | |
console.log("User Wins"); | |
} | |
// if else statement with || && | |
if (computerSelection === userSelection ) { | |
console.log("Tie"); | |
} else if ( (computerSelection === "rock" && userSelection == "scissors") || (computerSelection === "paper" && userSelection == "rock") || (computerSelection === "scissors" && userSelection == "paper") ){ | |
console.log("Computer Wins"); | |
}else { | |
console.log("User Wins"); | |
} | |
// Nested if else statements | |
if (computerSelection === userSelection){ | |
return "The result is a tie"; | |
} else if (computerSelection === "rock") { | |
if (userSelection === "scissors") { | |
return "rock wins";} | |
} else { | |
return "paper wins"; | |
} | |
} else if (computerSelection === "paper") { | |
if (userSelection === "rock") { | |
return "paper wins"; | |
} else { | |
return "scissors wins"; | |
} | |
} else if (computerSelection === "scissors") { | |
if (userSelection === "rock") { | |
return "rock wins"; | |
} else { | |
return "paper wins"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment