This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by peter.elbaum
over 8 years

Why am I getting an error with my syntax

I believe I have the correct code. I have consulted the forum but am still getting “unexpected token =”

Here is my code:

var compare=function (choice1, choice2) {
 if (choice1 === choice2){
return"The result is a tie!";
 } 
else if (choice1 === "rock") {
    
    if(choice2 ==== "scissors") {
        return "rock wins";
    }
    else {
        return "paper wins";
    }
}};

Answer 5602c96a3e0ec8570c00040d

1 vote

Permalink

One = is for assignment Two = compare the values Three = compare the values and types

But there isn’t an operator with 4 or more = as you used here :) (choice2 ==== “scissors”)

points
Submitted by haxor789
over 8 years

1 comments

peter.elbaum over 8 years

Thanks!