JavaScript - W033 - Missing semicolon

I try to copy the code after my JavaScript practice to ATOM.
but I got the Warning that W033 - Missing semicolon.
did I missing something??? =(
the same code was work on the lesson page…but not work on ATOM.

I don’t know why it worked on CodeCademy but yes, you need to end all your statments (eg return 7) with a semicolon.

Thank you for your reply!!
Yes, I did try to add a semicolon before. but I got the other Warning (W027 - Unreachable ‘break’ after ‘return’. )
it makes me more confuse…

Please post the entire code (not as a picture) .

In other words, break is not needed when there is a return within the case branch.

We only use break in a switch (or loop) if there is no return and the next instruction is after the switch body. break tells the interpreter to exit the switch and go to that instruction next.

When the switch is inside a function, return will exit that function, return to the caller, and carry out the next instruction just after that.

1 Like

In my opinion, having that many return statements inside a switch block is less than desirable. I would prefer to assign the number of sleep hours to a variable, leave the break;'s intact, and return the value of the variable after the switch block has finished. Like I said, just my opinion.

1 Like