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

String.prototype.trimStart() β€” leading tab

πŸ“– 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() β€” Tab Character

trimStart() also removes leading tabs.

Challenge: Implement removeLeadingTab(str) that removes a leading tab.

removeLeadingTab('\thello') // β†’ 'hello'
πŸ’‘ Hints (1)
  • β€’ `trimStart()` removes all leading whitespace: spaces, tabs (`\t`), and newlines (`\n`).