Rock, paper or scissors project

You must select a tag to post in this category. Please find the tag relating to the section of the course you are on E.g. loops, learn-compatibility

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

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:

const getUserChoice = userInput => { userInput = userInput.toLowerCase(); if (userInput === 'rock' || userInput === 'scissors' || userInput === 'paper') { return userInput; } else { console.log('Error, please type: rock, paper or scissors'); } }; const getComputerChoice = () => { const randomNumber = (Math.floor(Math.random() * 3)); switch (randomNumber) { case 0: return 'rock'; case 1: return "paper"; case 2: return "scissors"; } }; const determineWinner = (userChoice, computerChoice) => { if (userChoice === computerChoice) { return 'This game is a tie.'; } if (userChoice === 'rock') { if (computerChoice === 'paper') return 'The computer won!'; } else { return 'You won!'; } } if (userChoice === 'paper') { if (computerChoice === 'scissors') { return 'The computer won!'; } else { return 'You won!'; } } if (userChoice === 'scissors') { if (computerChoice === 'rock') { return 'The computer won!'; } else { return 'You won !'; } };

You have a } on line 32 that does not belong there. (It belongs all the way at the end of the code posted.)
It does not belong on line 32 because it would indicate the end of the determineWinner function, but the code after line 32 should be inside the determineWinner function.

Notice that you can change some of the ifs to else if.