JS Built-ins
← String179 / 195
StringString.prototype.trimEndbeginner

String.prototype.trimEnd() β€” no whitespace unchanged

πŸ“– Usage Example
'  hello  '.trimEnd()   // β†’ '  hello'
'text   '.trimEnd()    // β†’ 'text'
'hi'.trimEnd()         // β†’ 'hi'

Use trimEnd() to remove only trailing whitespace from the end of a string, leaving leading whitespace intact.

String.prototype.trimEnd() β€” Clean String

A string without trailing whitespace is returned unchanged by trimEnd().

Challenge: Implement verifyTrimEnd(str) using trimEnd.

verifyTrimEnd('hello') // β†’ 'hello'
πŸ’‘ Hints (1)
  • β€’ `trimEnd()` is a no-op when there is no trailing whitespace.