Do you know what will be the output of this code?
JavaScript
const n = 1;
switch (n) {
case 1:
console.log("one");
case 2:
console.log("two");
break;
default:
console.log("other");
}
Show answer and explanation
The answer is one, then two.
case 1 matches, but there’s no break, so execution falls through into case 2 and logs "two". The break there stops it before default.