Explore Library
Code QuizIntermediate

typeof Cannot Detect Arrays

A typeof check misidentifies arrays instead of using Array.isArray.

Codetypescript
function process(x: string | string[]) {
  if (typeof x === "array") {
    return x.join(", ");
  } else {
    return x.toUpperCase();
  }
}

What is the bug in this code?