Rock Paper Scissors Game


#1



Hi, I am attempting to create the rock, paper, scissors game, but I am having problems with my syntax. I believe my problem is within the first if in the function. Any help is appreciated. This is my code so far:

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

SyntaxError: Unexpected token if


var userChoice = prompt("rock, paper, or scissors?");
var computerChoice = Math.random();
if(computerChoice <=0.37)
{computerChoice = rock;
}
if(computerChoice <=0.67)
{computerChoice = paper;}
else {computerChoice = scissors;}
var game = function(user , computer)
if(user = scissors) 
{
    if(computer = rock); {
        console.log("computer wins!")
    }
    if(computer = paper) {
        console.log("Player Wins!");
    }
    else {console.log("its a tie!")}
    }
    if(user = rock){
        if(computer = scissors) {
            console.log(Player Wins!);
        }
        if(computer = paper) {
            console.log(Computer Wins!);
        }
    }
    if(user = paper){
        if (computer = rock) {
            console.log("Player Wins!");
        }
        if (computer = scissors) {
            console.log(Computer Wins!);
        }
    }
    }
game(userChoice, computerChoice)


#2

all the places where you use rock/scissors/paper you are using them as if they are object/variables already defined but that's not the case. you have to make them strings.

the equal**( = )** symbol is an assignment operator(assigning a number to a variable) and not a comparison operator. You cannot use it in an if condition

whenever you call console.log() you are passing illegal arguments. In your case you have to pass a string


#3

Thank you very much. Just started a couple days ago, so I am still working stuff out. Thanks again!