null checkif (obj === 'null') { return null;} // null unchanged
Here you’re comparing against the string "null", not the actual null.
So if you pass null, it will be treated as an object and go into the object-handling block.
✅ Fix:
if (obj === null) { return "null"; } // real null