Why is there a break; in the default case?



In the Hint section's syntax reminder for lesson All On Your Own, there is a break; after the default case and I was just wondering why it is there (mistake?).

While I'm asking, is it normal behavior that the console makes a sub-indent (instead of one at the same level) for each case which needs to be manually corrected, and no indent at all for the code under the default case?


case "1":
  case "2":

Just curious if it's only on my browser or something.

Thanks all,


Replace this line with your code.


Yes, break is unnecessary in the last block of switch (default in this case). Though it's not a mistake because it doesn't stop the program from running.

Regarding the behavior of code editor ("console" refers to browser console, seen on pressing F12) about adding tab spaces to your code automatically, while it may depend on the editor itself, but regarding the Codecademy editor, yes, after you have finished one case block and written break;, and when you press the [Tab] key, you do also need to press [Backspace] to delete the auto-inserted tab character and restore normal indent for the following case/default block.


Thank you so much, @gaurangtandon! In that case I will be sure to exclude default case breaks and keep an eye out for the indents in switch case.