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;
}

Explanation

switch uses strict equality. Without break, execution falls through into the next case.

Further reading

Problem with a question

JavaScript · Junior · question 64

Test yourself

Take the JavaScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz