JavaScript · Junior · Question 64 of 75
Which case runs for x = "1"?
switch (x) {
case 1: console.log("number"); break;
case "1": console.log("string"); break;
}- ✓Correct answer:
case "1"-switchcompares with=== - 2
case 1- values are converted - 3Neither
Explanation
switch uses strict equality. Without break, execution falls through into the next case.