JS Built-ins
StringString.prototype.charCodeAtbeginner

String.prototype.charCodeAt() β€” NaN for out-of-bounds

πŸ“– Usage Example
const str = 'ABC'
str.charCodeAt(0)   // β†’ 65
str.charCodeAt(1)   // β†’ 66
str.charCodeAt(99)  // β†’ NaN

Use charCodeAt() to get the UTF-16 code unit value of the character at the given index.

String.prototype.charCodeAt() β€” NaN

When the index is out of bounds, .charCodeAt() returns NaN.

Challenge: Implement codeOrNaN(str, i) and return true when the code is NaN.

codeOrNaN('hi', 99) // β†’ true  (NaN)
codeOrNaN('hi', 0)  // β†’ false (104)
πŸ’‘ Hints (1)
  • β€’ Use `isNaN()` to check the return value.