Can I get some help please!

Hi!

I am new to the coding world and this is my first post asking for help. HTML and CSS were straight forward but JS is a different story! I’m woking on the Rock, Paper, Scissors project and battling even with the YouTube video to help!

Project
https://www.codecademy.com/paths/web-development/tracks/getting-started-with-javascript/modules/learn-javascript-functions/projects/rock-paper-scissors-javascript

Here are two screenshots of my code. If I run just the code up to line 25, there are no errors. From line 26 down, it returns an error. I’ve compared it to the YouTube tutorial character for character and can’t for the life of me see what I’ve done wrong.

Any help would be appreciated, thanks!!

Do you have any code after line 50? If you copy your code and paste it into the post window, and then format it using the </> button then we can test it and replicate the issue ourselves!

1 Like

No, that’s the last line. Standby, I’ll do it now. Thanks Adam!

const getUserChoice = userInput =>
{
  userInput = 
userInput.toLowerCase();
if (userInput === 'rock' ||
userInput === 'paper'
|| userInput === 'scissors') {
  return userInput;
} else {
  console.log('Error');
  }
}

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 '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!';
  }
}

You’re just missing the closing bracket of the determineWinner() function that’s all! If you add an extra curly bracket at the very end, then you can call the function and it’ll work correctly.

3 Likes

Oh wow!! Thanks so much Adam. I would have been here all day looking for that! Embarrassingly simple. I hope this gets easier as I go!! I’m loving the journey but it’s a steep curve at the moment.

Have a great day! Rich :slight_smile:

1 Like