Stuck!


#1


The directions say.. inside the compare() function under the existing code, write another else if statement where the condition is choice1 === "paper"...BUT I have no clue how I should go about doing so. Help would be greatly appreciated. Thank you.

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


Oops, try again. Your code returned 'paper wins' instead of 'scissors wins' when the inputs are paper and scissors


Replace this line with your code. 
/*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) {//1.1
    if(choice1 === choice2) {//1.2
        return "The result is a tie!"; 
    }//1.2 FINISHED
    else if(choice1 === "rock") {//1.3
    
        if(choice2 === "scissors") {//1.4
            return "rock wins";
        }//1.4 FINISHED
        else {//1.5
            return "paper wins";
        } //1.5 FINISHED
    }//1.3 FINISHED//////////////////////////////
    if(choice1 === choice2) {//2.1/////////////////////////// NEW ELSE IF STATEMENT
        return "The result is a tie!"; 
    }//2.1 FINISHED
    else if(choice1 = "paper") {//2.2
    
        if(choice2 = "rock") {//2.3
            return "paper wins" 
        }//2.3 FINISHED
        else {//2.4
            return "scissors wins"
        } //2.4 FINISHED
    }//2.2 FINISHED
}//1.1 FINISHED


#2

@turnerscj,
-1
remove the 2nd

    if(choice1 === choice2) {//2.1/////////////////////////// NEW ELSE IF STATEMENT
        return "The result is a tie!"; 
    }//2.1 FINISHED

-2
In your IF or ELSE-IF condition's you should use the compare operator ===
instead of you using the assignment operator =

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators


#3

Thank you for the help @leonhard.wettengmx.n.