Logical operators - syntax error: syntax error


#1


Excercise I am stuck at: https://www.codecademy.com/en/courses/javascript-beginner-en-ZA2rb/0/5?curriculum_id=506324b3a7dffd00020bf661#


It constantly says "SyntaxError: Syntax error", even though I can't find a single mistake in my code (included below). Would be grateful if someone could help me out, because I seem to be really stuck.


var user = prompt("Are you ready?", "Enter your answer here").toLowerCase();
switch(user){
    case'yes':
        console.log("Hallelujah! Let's move on, then.");
        var yui = prompt("Are you STRONG or SMART?","Enter your pathetic answer here.");
        if(yui === 'smart') || (yui === 'strong'){
            console.log("It matters not, for you shall proceed anyway.");    
        }else{
            console.log("So neither? Such a pity.");    
        }
        break;
    case'no':
        console.log("Then you SHALL NOT PASS!!!");
        var oneone = prompt("Wait, turn back! One more chance! Are you ready?", "Enter yes here.");
        var twotwo = prompt("Are you sure?","Enter yes here.");
        if(oneone === 'yes') && (twotwo ==='yes'){
            console.log("FINALLY! OK, let's move on.");
        }else{
            console.log("I hope it was a misunderstanding, otherwise, someone is done for.");
        };
        break;
    case'dunno':
        console.log("Ditto.");
        break;
    default:
        console.log("What the hell did you enter? Is that supposed to be an answer???");
};


#2

@betasolver64029 You must remove these parans (these()):

if(yui === 'smart') << this || ( << and this yui === 'strong'){

if(oneone === 'yes') << this && ( << and this twotwo ==='yes'){

Hope this helps

Steven


#3

Thank you a ton, it actually worked! I just got used to checking for several conditions this way in C :slight_smile:


#4

That's great. Glad you got it.


#5

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