Logical Operators Code Your Own Adventure 2


#1



https://www.codecademy.com/en/courses/javascript-beginner-en-ZA2rb/0/5?curriculum_id=506324b3a7dffd00020bf661


My code is getting the green light but the game is not working correctly. When someone types "sorry", "yes" and "yes" it should come back with the if console.log "great! middle of the road works well" but it is skipping over the && if statement and printing the else console log statement.


var user = prompt("what kind of game do you like to play?").toLowerCase();

switch(user) {
    case 'chess':
        var white = prompt("do you prefer to play the white pieces (yes or no)?").toLowerCase();
        var black = prompt("do you prefer the black pieces?").toLowerCase();
        if(white === 'yes' || black === 'yes') 
        {
        console.log("good choice, both work"); } else {
        console.log("pick one to play");
        }
        break;
    case 'sorry':
         var competitive = prompt("do you always put your opponent back to start (yes or no)?").toLowerCase;
         var nice = prompt("do you let your opponent stay on the board if you get the sorry card?").toLowerCase();
         if(competitive === 'yes' && nice === 'yes') {
        console.log("great! middle of the road works well");
         } else {
        console.log("sounds like you are either nice or competitive when you play")
         }
         break;
    case 'chutes and ladders':
        console.log("some games never get old");
        break;
        default:
        console.log("I don't know that game");
};


#2

HI this line

var competitive = prompt("do you always put your opponent back to start (yes or no)?").toLowerCase;

it's missing the () to .toLowerCase should be .toLowerCase()


#3

Thanks, that fixed it :slight_smile: