Rock Paper Scissors Game

Hello, im sorry, im new here and a COMPLETE beginner, I’ve been trying to do the javascript RPS game but i keep getting and error even tho i followed all the steps. I searched some other answers but some (maybe earlier versions of the game) seem to be doing it a bit differently from the instructions i got. Thank you in advance.

var userInput = 'Rock'
userInput = userInput.toLowerCase();

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

function determineWinner(userChoice, computerChoice) {
if (userChoice === computerChoice); {
return 'Tie';}
if (userChoice === 'rock') {if (computerChoice === 'paper') {return 'Computer won';}
else {return 'User won'}
}
if (userChoice === 'paper') {if (computerChoice === 'scissors') {return 'Computer won';}
else {return 'User won'}
}
if (userChoice === 'scissors') {if (computerChoice === 'rock') {return 'Computer won'}
else {return 'User won';}}
if (userChoice === 'bomb') {{return 'User won'}
}
}

function playGame() {
 var userChoice = userInput;
 var computerChoice = getComputerChoice();
  console.log('User choice: ' + userChoice + ',  Computer Choice: ' + computerChoice );
  console.log(determineWinner(userChoice, computerChoice));
}

playGame();
1 Like

What seems to be the problem?

1 Like

Well, is it a codecademy error?
Anyway I see only one thing, you used double {} instead of one. Right now i don’t see any problems with your code.
But why are you making the older R.P.C. game instead of the newer one, this is in ECMAScript version 5, and the newer one is in ECMAScript version 6
(variables are let and const instead of var and they are using the arrow functions const name = (argument) => {code...} and i think it uses string interpolation which:

`Hello, my name is ${name}`

which would output(for example name is Jay):
hello, my name is Jay
)

1 Like

I registered recently tothis course and thats the way its teaching me in the instructions. So i should not be doing it that way?

Well that’s weird, do you get a syntax error or do you get a codecademy error(for example, the code works but you set a number to 1 instead of 2, but this is only an example)

Freeform projects don’t have an SCT.

Semi-colon does not belong there.

As mentioned already, check for stray braces that do not belong. Use lots of whitespace (linebreaks and indent) to see how your blocking is structured.

1 Like