Stuck on rock paper scissors

Hey guys,

I did this project multiple times, even with the help video, after 2 hours I still cant find where i did someting wrong.
Everything seems going right, but at the end when i call the playGame() i get this.

I hope someone can help me!

This is my code:

const getUserChoice = userInput => {
userInput = userInput.toLowerCase();
if (userInput === ‘rock’ || userInput === ‘paper’ || userInput === ‘scissors’) {
return userInput;
} else {
return(‘error, Please choose rock paper or scissors’);

const getComputerChoice = () => {
const randomNumber = Math.floor(Math.random() * 3);
switch (randomNumber) {
case 0:
return ‘rock’;
case 1:
return ‘scissors’;
case 2:
return ‘paper’;

const determineWinner = (userChoice, computerChoice) =>{
if (userChoice === computerChoice){
return ‘Its a tie’;
if (userChoice === ‘rock’){
if (computerChoice === ‘paper’){
return ‘Sorry, computer won!’;
} else {
return ‘you won’;

if(userChoice === ‘paper’){
if (computerChoice === ‘scissors’){
return ‘You lost’;
} else {
return ‘You won !’;

if (userChoice === ‘scissors’){
if (computerChoice === ‘rock’){
return ‘You looooooose’;
} else {
return ‘Yaaay you win’;

const playGame = () => {
const userChoice = getUserChoice(‘paper’);
const computerChoice = getComputerChoice();
console.log(You threw: ${getUserChoice});
console.log(The computer threw: ${getComputerChoice});

console.log(determineWinner(userChoice, computerChoice));


Amusingly, your lack of correct formatting when posting your code has had the effect of actually highlighting your error. :smiley:

Can you see why these might be wrong, why you’re getting the output you’re getting, and how you should change them to fix the problem? :slight_smile:


o m g hahaha thank you so much, sometimes you just dont see it and things just look the same :woman_facepalming: :woman_facepalming:

I kept going back to the first steps, never thought it would be the last step

1 Like

Haha, no worries.

I think you were meaning to put userChoice rather than getUserChoice, no? Seeing as how you called the relevant functions in the preceeding two lines. :slight_smile:

Yeah, sometimes you just can’t see the error despite staring at the code for ages. Happens to everyone at some point. :slight_smile: