What if choice1 is paper?


#1

`

its crazy , i've been trying to figure out this line of code for 2hrs now and I can't get it through my head.. It always says "Rock wins" idk how it must be something wrong with it.. anyone could help me?


#2

okay, so our compare function has 4 things, an if to check if choices are equal:

if (choice1 == choice2){
    return "The result is a tie!"
}

then we are adding 3 else if statement to determine what the user picked/chose, lets do one:

else if (choice1 == "rock"){

}

then inside our else if, we nest if and else to determine what the computer chose:

else if (choice1 == "rock"){
     if (choice2 == "paper"){

    } else {

    }
}

Follow this structure. Pay close attention to the curly brackets

add a second else if following the same structure for choice1 is paper


#3

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