Rock Paper Scissors

const determineWinnner = (userChoice, computerChoice) => {

if (userChoice === computerChoice) {

return ‘This game is a tie’;

}

if (userChoice === ‘rock’) {

if (computerChoice === ‘paper’){

return ‘The computer won!’;

} else {

return ‘User has won!’;

}

}

if (userChoice === ‘paper’) {

if (computerChoice === ‘scissors’){

return ‘The computer has won!’;

} else {

return 'User has won';

}

}

if (userChoice === ‘scissors’) {

if (computerChoice === ‘rock’) {

return ‘Computer has won!’;

} else {

return 'User has won';

}

}

};

console.log(determineWinner(‘rock’, ‘paper’));
Hi all. Here is my code.It keeps throwing determineWinner is undefined. In the console.log ‘paper’ will not appear as a string. The first quotation after the comma stays white and the the word paper is red. The last quotation is yellow but the the two final parenthesis and semi colon are also yellow. No matter what I do this won’t change and I am stuck in the undefined error.
thanks for any insight

Welcome to the forums!

You have a simple spelling error in the function declaration but otherwise the code should work. You spelled Winner using n 3 times:

const determineWinnner = (userChoice, computerChoice) => {

Also, when posting code you can press the small </> button in order to get the correct JS formatting in this forum editor.

Ahhhh thank you sir!!! Looked at it for so long I couldn’t see it. Have a great week and thanks for the extra eyes Mike!!

1 Like