5. Both choices


#1


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


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";
        }
    else 
        {
	    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!";)
        };


#2

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


#3

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