5. Adding to an exiting switch


#1


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


I don't think that's a primary color!

Oops, try again. Did you remember to add in a case for yellow?

var color = prompt("What's your favorite primary color?","Type your favorite color here");

switch(color) {
  case 'red':
    console.log("Red's a good color!");
    break;
  case 'blue':
    console.log("That's my favorite color, too!");
    break;
  //Add your case here!
  
  default:
    console.log("I don't think that's a primary color!");
}


#2

It looks like you just forgot to add your case for yellow as the instructions as you to put it in. "Our switch statement needs a case for 'yellow'. Add it in and make it log a string of your choice to the console (it should be different from the default string)." Go back and add one!


#3

var color = prompt("What's your favorite primary color?","Type your favorite color here");

switch(color) {
case 'red':
console.log("Red's a good color!");
break;
case 'blue':
console.log("That's my favorite color, too!");
break;
case 'yellow'
console.log("Really?")
break;
// Add your case here

default:
console.log("I don't think that's a primary color!");
}


#4

Well did it work or do you have another error?


#5

SyntaxError: Unexpected identifier


#6

looks like you forgot the : after yellow


#7

My teacher has a folder and I have the exact thing he has


#8

Did you add the : ? That can cause that error that you got so it wouldn't surprise me if that was it.


#9

I figured it out with you and the folder so thank you @bibleman13


#10

Well good! Hope your coding class goes well! :smiley:


#11

Thank you and if I need help I'll make sure to ask you.


#12

Yeah no problem! and if I am not on just post in the forums and there are many more capable guys and gals that can help you and other students that might need help in Javascript. Just make sure to include your code, error, and a link as you did with this one! :smiley:


#13

I will. Thank you. Happy Coding! LOL :smiley:


#14

:blush:
I think you are the nicest helper that I've had during this whole journey. :relieved:


#15

Well I appreciate it haha. I have only been coding for 8 months myself so I still remember being a complete newbie to coding so I try to be as gracious and helpful as possible since I know that is what I was looking for when I went for help on on here all those days ago. A guy named @williamwallacef14 was my first helper and I have modeled my approach after him.


#16

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