Not sure if this is correct


#1

//It says proceed to the next lesson but i dont think i have it completely done :confused:
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!"

}
else if (choice1 == "paper"){

if (choice2 == "rock"){

   return "paper wins"}

      else {
          return "scissors wins"
      }

   compare(userChoice,computerChoice);

}

};


#2

try this

var userChoice = prompt("Do you choose rock, paper or scissors?").toLowerCase();
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) {console.log( "The result is a tie!");}
                    else if (choice1 == "paper"){
                        if (choice2 == "rock"){console.log( "paper wins");}
                    else {console.log( "scissors wins");}
                    }

            };
compare(userChoice,computerChoice);

if you want to call your function like this compare(userChoice,computerChoice); then you need to console.log() the results but if you choose to return them you need to do

console.log(compare(userChoice,computerChoice));