JS Built-ins
StringString.prototype.charAtbeginner

String.prototype.charAt() β€” out-of-bounds returns empty string

πŸ“– Usage Example
const str = 'Hello'
str.charAt(0)    // β†’ 'H'
str.charAt(1)    // β†’ 'e'
str.charAt(99)   // β†’ ''

Use charAt() to get the character at a specific index, returning an empty string for out-of-bounds positions.

String.prototype.charAt() β€” Out-of-Bounds

charAt returns '' (empty string) for out-of-bounds, while .at() returns undefined.

Challenge: Implement isOutOfBounds(str, i) that returns true when .charAt(i) returns an empty string.

isOutOfBounds('hi', 99) // β†’ true
isOutOfBounds('hi', 0)  // β†’ false
πŸ’‘ Hints (1)
  • β€’ Unlike `.at()`, `.charAt()` does NOT support negative indices β€” they are treated as 0 or out-of-bounds.