5. Both choices



I'm getting "Oops, try again. There was a problem with your syntax." What am i doing wrong?

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";
	    computerChoice = "scissors";
    console.log("Computer: " + computerChoice);
var compare = function(choice1,choice2)
    var choice1 = userChoice
    var choice2 = computerChoice
    if(choice1 === choice2)
        return("The result is a tie!";)


functions should use curly brackets:

var example = function(){


to mark the start and end of the function, the curly brackets are missing in your case

don't overwrite your function parameters (choice1 and choice2), you can supply userChoice and computerChoice as arguments when you call the function


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