7/9 is very confusing


#1

Inside the compare() function under the existing code, write another else if statement where the condition is choice1 === "paper".

I don't know how to play this game and, thus, the instructions are not sufficient. So, is it really under? Is it not interleaved?

I'm sorry, these culture-specific games are difficult to grasp outside some boundaries, just like imperial measures, American football and baseball. But I digress.


#2

see this

/*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 === "rock") {
            if(choice2 === "scissors") {
                return "rock wins";
                } else {
                    return "paper wins";
                    };
            } else if (choice1 === "paper") {
                if(choice2 === "rock") {
                    return "paper wins";
                    } else {
                        return "scissors wins";
                        }
                
                }
            
            
            ;
    
};

#3

Better get rid of the semicolons after your elses.


#4

thanks! a lot for your advice :smile:


#5

Maybe have a look at this post's post:
https://www.codecademy.com/forum_questions/51fc4178f10c60f4eb001233#answer-54917bd395e378bc1f001cf4
or google RPS its a really simple game and the underlying logic of many real time strategy games :smile:


#6

That's exactly the info I was looking for! Thank you very much! With that table, I should be able to program it properly!