rockPaperScissors Project

Hey I have been picking my brain for two days. Can someone please tell me where I went wrong

const getUserChoice = userInput => {
  userInput = userInput.toLowerCase()

  if (userInput === 'rock' || userInput === 'paper' || userInput === 'scissors') {
    return userInpit
  } else {
    console.log('Error')
  }

  function getComputerChoice() {
    switch (Math.floor(Math.random) * 3) {
      case 0:
        return 'rock'
      case 1:
        return 'paper'
      case 2:
        return 'scissors'
    }
  }

  function determineWinner(userChoice, computerChoice) {
    
    if (userChoice === computerChoice {
        return 'The game is a tie'
    } 

    if (userChoice === 'rock') {
      if (computerChoice === 'paper') {
        return 'Computer Won!'
      } else {
        return 'User Won!'
      } 
    }

    if (userChoice === 'paper') {
      if (userChoice === 'scissors') {
        return 'Computer Won!'
      } else {
        return 'User Won!'
      }
    }

    if (userChoice === 'scissors') {
      if (userChoice === 'rock') {
        return 'Computer Won!'
        } else {
        return 'User Won!'
        }
    }

  }

  const playGame = () => {
    let userChoice = getUserChoice('rock')
    let getComputerChoice = getComputerChoice {"scissors"}
    console.log(`You choose ${userChoice}`)
    console.log(`The computer choose ${getComputerChoice}`)
    console.log(determineWinner(userChoice, computerChoice))
  }

  playGame()

If I look at these two lines:

    let userChoice = getUserChoice('rock')
    let getComputerChoice = getComputerChoice {"scissors"}

both getUserChoice and getComputerChoice are function calls, yet you use very different syntax for both calls. Why? There is only one way to call/invoke functions

I figured it out almost right after I posted. Now when I run it I get no errors but my whole switch statement shows up. It’s weird. Any thoughts?

here:

const getUserChoice = userInput => {

you start your getUserChoice function, but I never see a curly bracket to close your function

if you have further questions, please included an updated version of your code

Ahhhhhh…youre right! Thank you!

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.