Functions ("Both choices are same")


#1

what's wrong with my code below? I put on comment as per instruction:
We carried over the code from the previous section, but it is a comment. Leave it there for now.
Below the comment, declare a function called compare.
It takes two parameters, choice1 and choice2.
Inside the function, write an if statement. If choice1 === choice2, then return "The result is a tie!"

/*
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){
if (choice1 === choice2){
return "The result is a tie";
}
};

I tried calling it and comparing with some values, but it gives me error saying It does not return as expected


#2

ok solved, forgot to put ! in "The result is a tie"


#3

Hi there,

Make sure to but the semi colon ; after the function also after the if statement