The original ternary "fixes" the cases where `x` is "wrong" (e.g., is not a string - `x.length` does not fail, but evaluates to false, and thus you still get `<empty>`).
This even more terser code will fail if `x.toUpperCase()` fails with an exception (such as when x is not a string).
Given the example I think it is reasonable to assume it is always an string; otherwise if there is any possibility that x is not a string you can just use optional chaining:
This even more terser code will fail if `x.toUpperCase()` fails with an exception (such as when x is not a string).