A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-168.js
1switch(true){
2casetrue:
3varhit="yes";
4default:
5varhit2="fall";
6}
7console.log(hit,hit2);
Scope
Answer & explanation
Console output
yes fall
Why
Without a break, the matched case true falls through into the default clause, running both assignments. Because var is function-scoped (not block-scoped), hit and hit2 both leak out of the switch and are visible to the console.log, printing "yes fall". This combines two classic pitfalls: switch fall-through and var’s indifference to block boundaries.