8. Make sure you have a break statement for each case


#1

var variable = prompt("Enter your case here!","Your case goes here");

switch(variable) {
case 'First case':
console.log("This is the first case");
break;
case 'Second case':
console.log("This is the second case");
break;
case 'Third case':
console.log("This is the third case");
break;
default:
console.log("Invalid case");
break;
}

It says "Oops, try again. Make sure you have a break statement for each case."
But I did use the break statement for each case.
Please help me.


#2

hello @_toxicxcoder,

Why does your prompt statement have two arguments? Other than that, I can't think of anyway your code in incorrect. Try refreshing the bag, that fixes the problem sometimes.


#3

When you are using two arguments for a prompt the way I used it, It is adding a placeholder to the prompt, Try it, It's cool.


#4

The code checker is matching up case and break -- you have a lot more cases because you've used them in your console.log messages. If you really want those, you can work around it by adding more breaks.

-- the code checker is not too smart


#5

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