Rock Paper Scissors Project determineWinner logic flaw

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!
Hi! I’m doing the rock paper scissors project and when I log

console.log(determineWinner(‘scissors’, ‘paper’));
// prints out computer wins when it should print user wins!

Ive attached my code below if anyone can help find where I went wrong

const determineWinner = (userChoice, computerChoice) =>{
  if (userChoice === computerChoice) {
    return 'It is a tie!';
  } else if ( userChoice === 'rock') {
    if (computerChoice === 'paper') {
      return 'Computer won!';
    } else {
      return 'User won!'
  if (userChoice === 'scissors' ){
    if (computerChoice = 'rock') {
      return 'Computer won!';
  if (userChoice === 'paper') {
    if (computerChoice === 'scissors') {
    return 'Computer Won!';
    } else if (computerChoice === 'rock'){
      return 'User Wins!'

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer! :slight_smile:

1 Like


if (computerChoice = 'rock')

why do you assign? All the other conditions use the equal comparison correctly, but here not.


I originally used the wrong operators and I missed that one when I went back to edit it. Thank You! I will fix it now and try to run it again

1 Like

Thank you so much! I needed to change the comparison operator AND fix my conditional by adding
to my if/else statement.

if (userChoice === ‘scissors’ ){
if (computerChoice ===‘rock’) {
return ‘Computer won!’;
} else if (computerChoice === ‘paper’){
return ‘User won!’