charAt()

Page section: posts

The charAt(n) method finds the nth character of a string.

const bird = 'Ostrich';

const birdFirstLetter = bird.charAt(0);

There are other methods of getting a letter from a string:

  • bird.charAt(0)
  • bird.substring(0, 1)
  • bird.slice(0, 1)
  • bracket notation bird[0]

More on this at W3 Docs.