More practice with Switch


#1


Hi there

I don`t know why it is showing this message: ReferenceError: countries is not defined

I am sure I did everything right. Please help! Thanks

https://www.codecademy.com/en/courses/javascript-beginner-en-qDwp0/1/3?curriculum_id=506324b3a7dffd00020bf661


var answer = prompt("Which countries have you ever been to?");

switch (countries) {
case 'Chile':
    console.log("Only for a day");
    break;
    case 'Argentina':
    console.log("honey moon");
    break;
    case 'Australia':
    console.log("In 2013");
    break;
    default:
    console.log("Next one to EUA");
  // Add your code here!
}


#2

yes you prompt the user to name a country and store it in a variable named answer. And then you use countries instead of answer in the switch.


#3

Hi there

I as well, do not know what's wrong with my code and it kept showing this message : Oops, try again. There was a problem with your syntax.
I checked over and over again to see where I went wrong but in the end I couldn't find the mistakes.
Please help me!
Thank you in advance.

var userAnswer = prompt("What is your favourite movie?/ Type in common letters please.");

switch(userAnswer){
    case 'now you see me':
    console.log("Yeah, I love that movie especially the part where the hypnosis guy tells the tale of the assistant french police lady. That was cool.");
    break;
    case 'now you see me 2':
    console.log("Bruh, I dig that movie. KFC: Ah eat that. Your Xs number: ah own that. Now you see me 2: AH WATCH THAT!");
    break;
    case 'angry birds':
    console.log("That movie was cool and all. Especially when the Guidance Counsellor beat up those piggies. She was like,'I'm gonna kick your ass to the night before!' Yeah she's cool.");
    break;
    case 'zootopia':
    console.log("I like that movie its full of animals. But you know what I don't like about that movie! They are all racist! Not a single ape black animal confirmed throughout the movie.");
    break;
    case 'batman vs superman':
    console.log("Batman would have won! He was all over superman! But did you know? Superman didn't really die in the end! I'm telling you he's freakin' BAF.");
    default:
    console.log("Doug you must be crazy, There ain't no " + userAnswer "movie. You lyeing.");
}

#4

your missing a "+" after userAnswer and before "move...".


#5

Thank you so much!
I type it in and it actually worked!
God bless you!


#6

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