Switch


#1

It keeps telling me that I need to add a break after each case. No syntax error, just the error message.

<do not remove the three backticks above>

#2

How strange, the code you posted doesn’t have any errors. It may be something to do with the question asked, please upload the question as well.

If not then its a bug :frowning:


#3

Here’s the exact question.
“After your prompt, add a switch statement that will test for several different cases (that is, different possible user inputs). Create as many as you like! (Do at least three.) Don’t forget to include a default block at the end that will provide a response if the user’s choice doesn’t match one of your cases.”

Here are the additional screen shots so you can see that the prompt seems correct and the log is correct. However, it gives the error and won’t let me proceed.


#4

Easiest if you just post a link to the exercise. That way we can read and test code.

It is not needed on the default case, but for the sake of the SCT, you may need to write a break there, too.


#5

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

Got it!


#6

Still doesn’t seem to be working. Any ideas or should I report it as a bug?


#7

We still need to test your code. Please post the raw text, not a picture.


#8

var user = prompt (“What day is it? Monday, Tuesday, Wednesday, Thursday or Friday?”);

switch(user){
case’monday’:
console.log(“Looks like someone has a case of the Monday’s!”);
break;
case’tuesday’:
console.log(“Could be worse. Could still be Monday!”);
break;
case’wednesday’:
console.log(“Hey Mike. What day is it? It’s HUMP DAY!!!”);
break;
case’thursday’:
console.log(“Almost Friday!”);
break;
case’friday’:
console.log(“You made it!”);
break;
default:
console.log(“It’s “+ user +” , enjoy your weekend!”);
}


#9

I was able to reproduce the error with your code, and passed with this…

user = user.toLowerCase();
switch(user){
case'monday':
  console.log("Looks like someone has a case of the Monday's!");
  break;
case'tuesday':
  console.log("Could be worse. Could still be Monday!");
  break;
case'wednesday':
  console.log("Hey Mike. What day is it? It's HUMP DAY!!!");
  break;
case'thursday':
  console.log("Almost Friday!");
  break;
case'friday':
  console.log("You made it!");
  break;
default:
  console.log("It's "+ user +" , enjoy your weekend!");
  break;
}

#10

I assume that this picks up on the line after the prompt set up?


#11

Correct. I left that line off the post, only.


#12

MTF - Thank you for the help! FINALLY got it to post.


#13

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