GETTING STARTED WITH JAVASCRIPT Rock, Paper, or Scissors

https://www.codecademy.com/paths/web-development/tracks/getting-started-with-javascript/modules/learn-javascript-functions/projects/rock-paper-scissors-javascript
Hello this is my code for the first 4 steps of the task. I am coping exactly what the video says but my last to brakets keep showing in color red instead of white. I don’t know if that means something is wrong or if i can keep coding without problem.

Thanks!!

My code:

const getUserChoice = userInput => {

  userInput = userInput.toLowerCase();

if (userInput === 'rock' || userInput === 'paper' || userInput === 'scissors') {

  return userInput

  } else {

  console.log ('Error!');

  }

};

looks fine, if we add function calls to test your code:

const getUserChoice = userInput => {

  userInput = userInput.toLowerCase();

if (userInput === 'rock' || userInput === 'paper' || userInput === 'scissors') {

  return userInput

  } else {

  console.log ('Error!');

  }

};


console.log(getUserChoice('Rock'))
getUserChoice('invalid');

everything seems to add up.

you could put your code in your local text-editor/IDE if you have that setup. I think its a problem with codecademy colors/IDE. nothing to worry about

1 Like

I played with your code a bit in the CC editor. It doesn’t like the space here:

console.log ('Error!');
           ^

Typically you don’t include a space between a function/method name and the parenthesis in a function/method call. Not a big deal, but if you don’t like the red }'s, you can delete the space.