Logical Operators


#1


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


SyntaxError: Unexpected token var

var answer = prompt("you see a guy touching your girlfriend you tell him to stop and he says make me. do you FIGHT, RAP battle, or WALK AWAY? ").toUpperCase()

switch(answer) {
    case'FIGHT':
        var strong= prompt("are you STRONG?YES/NO").toUpperCase();
        if(var strong==="YES") {
            console.log("THen beat him up and tell him to apologize to your girlfriend");
        }
        else{
            console.log("you still have got to fight, she is your girl friend");
    break;
    case'RAP':
        var rap=prompt("Do you know how to rap?YES/NO").toUpperCase();
        if (rap==="YES"){
            console.log("Let's hear it");
        }
        else{
            console.log("Here use this" + "www.directlyrics.com/eminem-lose-yourself-lyrics.html");
        }
    break;
    case'WALK' || 'WALK AWAY':
        console.log("you're a coward!").toUpperCase();
        break;
        default:
        console.log("Wrong input! Please restart and choose one of the following: FIGHT, RAP, or WALK AWAY");
};

`


#2

Remove the var in the condition. You just want to evaluate strong and that takes a value entered in response to the prompt on the previous line.

Also, for your case 'WALK||WALK AWAY', have a look at this faq:


#3

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