7. More practice with switch


#1



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

I don't know what's wrong with my code. When I hit the button to move on, I don't get anything inside the little black box on the right. This makes me think it's not right. I'll be happy if it is correct but if no statement shows up, how can it be?


var Dinner = prompt("Where do you want to go for eat?  Please answer here!");
 
switch(Dinner) {
  case 'Olive Garden':
    console.log("I was thinking about Italian food");
    break;
   switch(Lunch) {
    case 'Burger King':
    console.log("I'm not that hungry");
      break;
  // Add your code here!
  default:
  console.log("I don't like " +  + ".  I really wanted to go to The Red Lobster");
   } 
}


#2

for your default then you have two plus signs when you only need one.


#3

That makes sense to me but when I took out the one plus sign, the box still remains empty. The default doesn't even show up.


#4

What reference error are you getting?


#5

I'm not getting any reference error. I just thought that if the box remained empty, the code must not be correct.


#6

Have you tried running the default by saying something like in'n'out?


#7

No, I haven't tried that.


#8

Where would that go anyway?


#9

That is probably why it isn't showing up, you are probably saying something like Burger King and it isn't running the default. Try saying "Italian Restaurant" and see what it says.


#10

A pretty big part of your code can't be reached at all.
Your code runs and it just doesn't trigger any cases, hence printing nothing.


#11

I also just noticed, when you said switch(lunch), you never defined lunch.


#12

hmmmmm, that makes sense too. I'm going to look at it a little more and see what I can do to fix it. Thank you for your help, I truly appreciate it. I know this isn't easy but I'm not giving up. I actually like it.


#13

That's good :slight_smile: Whenever you face problems and then solve them then your brain becomes a tiny bit stronger, keep on working on it. You will get it eventually and you will feel a very deep satisfaction.


#14

I'm feeling satisfied already. You have been a huge help to me today, thank you.


#15

Your welcome, keep up the good work :slight_smile:


#16

var Dinner = prompt("Where do you want to go for eat? Please answer here!");

switch(Dinner)
{
    case 'Olive Garden':
    console.log("I was thinking about Italian food");
    break;

    case 'Burger King':
    console.log("I'm not that hungry");
    break;
default:
console.log("I don't like " + Dinner + ".  I really wanted to go to The Red Lobster");
}

fixed**** study this and stop using spaces