Problem, as an interviewer would state it:
"Implement String.prototype.myTrim from scratch — removing leading AND trailing whitespace, matching real native trim's own complete, documented definition of whitespace (spaces, tabs, newlines, and other Unicode whitespace characters), while preserving any internal whitespace."
Examples:
" hello world ".myTrim(); // "hello world"
Clarifying questions expected:
- Does "whitespace" for this purpose genuinely need to include tabs and newlines, not just plain spaces?
- Should INTERNAL whitespace (between words) be genuinely preserved, only the LEADING and TRAILING whitespace removed?
- Should this correctly coerce a non-string
this(viaString(this)), matching real, generic string-method behavior?
Code / implementation expected: Yes — real, direct proof matching real native trim across spaces, tabs, and newlines, confirming internal whitespace is genuinely preserved.