Unexpected Token if Please Help


#1

UNEXPECTED TOKEN if Please Help

https://www.codecademy.com/en/courses/javascript-beginner-en-Bthev-mskY8/1/1?curriculum_id=506324b3a7dffd00020bf661


var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
	computerChoice = "rock";
} else if(computerChoice <= 0.67) {
	computerChoice = "paper";
} else {
	computerChoice = "scissors";
} console.log("Computer: " + computerChoice);
var compare = function(choice1,choice2)
//This is an if statement to declare a tie.
if(choice1 === choice2)
{
    return "The result is a tie!"
}


Replace this line with your code.


#2

Please post your code, we will be happy to help you, but we need to see your code :slight_smile:

And please remember about formatting the code. You can do that by highlighting all of your code while editing / creating a post, and clicking the </> icon in the formatting bar above the text area.


#3

im sorry i'm new to this how do i show my code. I left a link to my lesson if that will help you.


#4

This is just a link to the exercise, I can't see your code there :slight_smile:

You have to copy your code and paste here.


@iliketurtles2939 everything is ok with your if, but you need to surround body of your compare function using the braces:

var compare = function(choice1,choice2) {
    //This is an if statement to declare a tie.
    if(choice1 === choice2)
    {
        return "The result is a tie!"
    }
};

#5

Have you looked at my first post edited it again


#6

And I have edited my post :slight_smile:


#7

Thank you so much, your help was greatly appreciated!:relaxed:


#8

You're very welcome! :slight_smile:


#9

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