Let’s emphasize that the equality check is always strict.
Any expression can be a switch/case argument
For 0, 1, the first alert runs. For 2 the second alert runs. But for 3, the result of the prompt is a string "3", which is not strictly equal === to the number 3. So we’ve got a dead code in case 3! The default variant will execute.
Please note: the break at the bottom is not required. But we put it to make the code future-proof.
f there is no break then the execution continues with the next case without any checks
Glasp is a social web highlighter that people can highlight and organize quotes and thoughts from the web, and access other like-minded people’s learning.