JS Built-ins
StringString.prototype.charAtbeginner

String.prototype.charAt() β€” last character

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

Use str.length - 1 to get the last character index.

Challenge: Implement lastCharAt(str) using .charAt(str.length - 1).

lastCharAt('hello') // β†’ 'o'
lastCharAt('abc')   // β†’ 'c'
πŸ’‘ Hints (1)
  • β€’ The last index is `str.length - 1`.