JS Built-ins
← String182 / 195
StringString.prototype.trimStartbeginner

String.prototype.trimStart() β€” trailing spaces preserved

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

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

String.prototype.trimStart() β€” Trailing Spaces Preserved

trimStart() does NOT touch trailing whitespace β€” only leading whitespace is removed.

Challenge: Implement trimStartOnly(str) that removes leading but preserves trailing whitespace.

trimStartOnly('  hello  ') // β†’ 'hello  '
πŸ’‘ Hints (1)
  • β€’ `trimStart()` is asymmetric β€” it only affects the left side of the string.