Problem with own rock, paper, scissors


#1

Hi.

I would like to give thank to all those people that have helped me with lesson 12.

Your help is appreciated.

But now I have a problem with lesson 13, and I have decided to ask for help, again.

I have inserted the code and I always get the same message "Oops, try again.
There was a problem with your syntax.", but I have no idea what I'm doing wrong.

Can you please help me?

Thank you.


The code I have inserted is:


var userChoice = prompt("Do you choose Rock, Paper, Scissors?");
var secondplayerChoice  = prompt("What is your choice Second Player");

console.log("First Player Choice:" + userChoice);
console.log("Second Player Choice:" + secondplayerChoice);

var compare = function(firstChoice,secondChoice)

if (firstChoice: === secondChoice){
console.log("The result is a tie!. Please make a new choice...");
}
else{
if (firstChoice === Rock){
  if (secondChoice === Paper){
  console.log("Paper Wins");
else if (secondChoice === Scissors){
  console.log("Rock Wins");
else{
if (firstChoice === Paper){
  if (secondChoice === Rock){
  console.log("Paper Wins");
else if (secondChoice === Scissors){
  console.log("Scissors Wins");
else{
if (firstChoice === Scissors){
  if (secondChoice === Rock){
  console.log("Rock Wins");
else if (secondChoice === Paper){
  console.log("Scissors Wins");
}
}
}
compare(userChoice,secondplayerChoice)


#2

If I'm not wrong, isn't Lesson 13 of Introduction to Functions in JS this: https://www.codecademy.com/en/courses/javascript-beginner-en-6LzGd/2/5?curriculum_id=506324b3a7dffd00020bf661?

Are you referring to the Build Rock, Paper, Scissors lesson?

If so,
1.You have an extra : in your first if statement

if (firstChoice: === secondChoice){

2.All your inputs are strings, so your conditions have to deal with strings and not variables as this is what you have as your conditional statements (check all your statements!):

if (firstChoice === Rock /*<= should be a string: "Rock" */){
  if (secondChoice === Paper /*<= should be a string: "Paper" */){

3.Else statements are used as a last conditional kind of thing. General structure should be something like this:

if() {
    //Do something
}else if() { //This is a nested condition example
    if() {
        //Do something
    }else if() {
        //Do something
    }else {
        //Do something
    }
}else if() {
    //Do something
}else {
    //Do something
};

4.Watch where you put your closing curly brackets! }. You're missing some.
5.Don't forget your semicolon at the end of your function!


#3

Thank you.
Problem Solved.


#4