I'm stuck on this problem. need help


#1



var computerChoice = Math.random();
if (computerChoice < 0.34) {
	computerChoice = "rock";
} else if(computerChoice <= 0.67) {
	computerChoice = "paper";
} else {
	computerChoice = "scissors";
};

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";
       }
    } 
else if{(choice1 === "scissors"){
if(choice2 === "paper"){
return "scissors wins";
}else{
return "rock wins";
       }
    } 
else if{(choice1 === "paper"){
if(choice2 === "rock"){
return "paper wins";
}else{
return "scissors wins";
       }
    }
};
console.log(userChoice,computerChoice);


Replace this line with your code. 



#2

What error are you getting?


#3

its the ')' error code, I've looked everywhere but I can not find any missing or extra parenthesis. I thought I had the format correct


#4

Try removing the opening { here and for the else if statements and ensuring you have the correct number of opening and closing brackets after that. There's only suppose to be the last one on that line, not the one in the middle.


#5

Thanx, I'm almost there, now I'm getting a code that says make sure you call the function using userChoice and computerChoice as the arguments. I tried it with or without console.log but it keeps popping up


#6

sorry for the late response lol

Try putting "compare(user.choice,computer.choice"

Actually I might be getting how to call functions in Python and JavaScript mixed up lol review how to call functions though. That part doesn't look correct to me.


#7

Thanks a lot, I really appreciate the help. It worked I forgot the function was actually called compare. I've been stuck on that same lesson for like a week


#8

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