E0458: typeof result is of type string and so will never equal undefined; use 'undefined' instead
The typeof
operator will always return a string, so comparing to undefined will always yield false.
(MDN)
Instead, compare against the string "undefined"
: