I have been stuck on this for so long, basically its a human vs computer, I type in say Rock and it gives me you chose rock you win, even when i chose the others it still returns that, can someone help me to figure out why it keeps doing this?
let person = prompt ("Rock, Paper, Scissors");
// Computer makes a choice
function computerPlay () {
let compchoice = ['Rock', 'Paper', 'Scissors'];
return compchoice[Math.floor(Math.random() *
compchoice.length)];
}
//Player vs Computer
function playRound (playerSelection, computerSelection) {
if (playerSelection === 'Rock' || computerSelection ===
'Scissors') {
return 'You chose ' + playerSelection + ',' + ' You win!';
} else if (playerSelection === 'Paper' || computerSelection ===
'Rock')
{
return 'You chose ' + playerSelection + ',' + ' You win!';
} else if (playerSelection === 'Scissors' || computerSelection ===
'Paper')
{
return 'You chose ' + playerSelection + ',' + ' You win!';
} else if (computerSelection === 'Rock' || playerSelection ===
'Scissors')
{
return 'Computer chose ' + computerSelection + ',' + 'Computer
wins!';
} else if (computerSelection === 'Paper' || playerSelection ===
'Rock')
{
return 'Computer chose ' + computerSelection + ',' + 'Computer
wins!';
} else if (computerSelection === 'Scissors' || playerSelection ===
'Paper')
{
return 'Computer chose ' + computerSelection + ',' + 'Computer
wins!';
} else if (computerSelection === playerSelection) {
return 'Its a draw!';
}else {
return 'Please chose Rock, Paper, or Scissors';
}
}
const playerSelection = 'rock';
const computerSelection = computerPlay();
console.log(playRound(playerSelection, computerSelection));
It should just play a regular game of rock paper scissors, if i chose rock and the computer chose paper the computer should win. For now i am trying to make it play just one round.