Create Your Own Adventure


#1


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

Oops, try again. There was a problem with your syntax. SyntaxError: Unexpected token else

How can I have a token "else" when the assignment says I should have the "else" in there?


var user = prompt("Where do you think your going?").toUpperCase;
var user = prompt("Name?");

switch(user) {
    case 'Juno':
        console.log("Hey, what kind of name is that?");
        if (Juno == true && name  == "Juno"); {
        }
        else (June == false name " "); {
            console.log("What is your real name?");
}
        break;
        
    case 'Dionne':
        console.log("Weren't you supposed to be at the party?");
}
        if (Dionne == true || name == "Dionne"); {
        }
        else (Dionne == false name " "); {
        console.log("Are you sure that's correct?");
}
        break;
        
    case 'Adrian':
        console.log("Adrian McNeill! is that you?");
        
        if (Adrian == true || name == "Adrian"); {
}
        else (Adrian == false name " "); {
            
        console.log("I thought you were Adrian McNeill.");
}
        break;
            
    default:
        console.log("You're not the one I've been looking for!");
}


#2

@mrs2nsmith,
-1 Within an IF ELSE statement structure you do NOT use semi-colons-;
-2 An ELSE statement does not take a condition

if ( condition ) {
   //IF code-block
}
else {
   //ELSE code-block
}

#3

This is my new code after I made changes and I'm still getting the syntax error. SyntaxError: Unexpected identifier - What am I doing wrong? Am I missing quotes, parenthesis, brackets? I just don't see it. Please help.

var user = prompt("Where do you think your going?").toUpperCase;
var user = prompt("Name?");

switch (user) {
case 'Juno':
console.log("Hey, what kind of name is that?")
if(Juno == true && name == "Juno") {} else(Juno == false name "not Juno")
console.log("What is your real name?")
}
break; {
case 'Dionne':
console.log("Weren't you supposed to be at the party?")

    if(Dionne == true && name == "Dionne") {} else
    return("Are you sure that's correct?")

}
break; {
case 'Adrian':
console.log("Adrian McNeill! is that you?")

    if(Adrian === true || name == "Adrian") {} else
    return("I thought you were Adrian McNeill.")

}
break; {
default: console.log("You're not the one I've been looking for!")

}


#4

@mrs2nsmith,
Please read the documentation
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else
and
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch