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

String.prototype.startsWith() β€” no match

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

Returns false when the string does not start with the given prefix.

Challenge: Implement doesNotStartWithA(str) that returns true if str does NOT start with 'A'.

doesNotStartWithA('Banana') // β†’ false
doesNotStartWithA('cherry') // β†’ true
πŸ’‘ Hints (1)
  • β€’ `startsWith` is case-sensitive, so `"a"` and `"A"` are different.