JS Built-ins
← String133 / 195
StringString.prototype.startsWithbeginner

String.prototype.startsWith() β€” case-sensitive

πŸ“– Usage Example
const str = 'Hello, World!'
str.startsWith('Hello')         // β†’ true
str.startsWith('World')         // β†’ false
str.startsWith('World', 7)      // β†’ true

Use startsWith() to check if a string begins with a specific prefix, with an optional start position.

String.prototype.startsWith() β€” Case Sensitivity

.startsWith() is case-sensitive. 'Hello' does not start with 'hello'.

Challenge: Implement startsWithExact(str, prefix) that checks the prefix case-sensitively.

startsWithExact('Hello', 'hello') // β†’ false
startsWithExact('Hello', 'Hello') // β†’ true
πŸ’‘ Hints (1)
  • β€’ `startsWith` performs a case-sensitive comparison.