Javascript rock paper scissors project

const getUserInput = (userInput)=>{ userInput=userInput.toLowerCase(); if(userInput===‘rock’||userInput===‘paper’||userInput===‘scissor’){ return userInput; }else { console.log(“your choice o f input is invalid”) }; }; console.log(getUserInput(‘ROCK’)) const getComputerChoice=() =>{ const number = Math.floor(Math.random()*3); switch(number){ case 0 : return ‘rock’; break; case 1 : return ‘paper’; break; case 2: return ‘scissor’ } } console.log(getComputerChoice()) const determineWinner = (userChoice,computerChoice)=>{ if (userChoice===computerChoice){ return ‘the game was a tie’; } if (userChoice===‘paper’){ if (computerchoice===‘rock’){ return ‘the user is the winner’ }else if(computerChoice===‘scissor’){ return ‘the computer is the winner’ } } if (userChoice===‘rock’){ if (computerChoice===‘paper’){ return ‘the computer is the winner’; }else if(computerChoice===‘scissor’){ return ‘the user is the winner’; } } if (userChoice===‘scissor’){ if (computerChoice===‘paper’){ return ‘the user is the winner’; }else if(computerChoice===‘rock’){ return ‘the computer is the winner’; } } } console.log(determineWinner(‘rock’,‘paper’)); const playGame= ()=>{ }

GUYS WHY CANT WE USE THE GETUSERINPPUT AND GET COMPUTER INPUT AS PARAMETERS FOR THE DETERMINE WINNER FUNCTION

1 Like

When posting code here don’t forget to click the image button and pasting the code between the image quotes.

1 Like
const determineWinner = (getUserChoice, getComputerChoice) => {
  return determineWinner;
	if(userChoice === computerChoice);
  	return 'The 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!";
    }
  }
};

I think this may be where the user got stuck. I am also stuck, I have even watch the walk-through video and cannot figure out where I went wrong. When I type in:

console.log(determineWinner('paper', 'scissors'));
console.log(determineWinner('paper', 'paper'));
console.log(determineWinner('paper', 'rock'));

it responds with this message:

[Function: determineWinner]
[Function: determineWinner]
[Function: determineWinner]

You need to delete the line I’ve commented on in your code. That return statement is executed as soon as your function starts to run, and terminates the function with the output you are seeing. I’ve made several additional comments regarding syntax errors. Please review, and let me know how it goes.