Find the Char
Explore how to access single characters in JavaScript strings using methods like charAt and bracket notation. Understand how to locate characters and substrings with indexOf, lastIndexOf, and boolean checks with includes, startsWith, and endsWith. This lesson helps you manipulate strings effectively in JavaScript.
We'll cover the following...
Accessing individual characters in a string
Even though JavaScript doesn’t have a char data type, it can still separate each string into individual characters.
We can find out a particular character in a string by using the charAt()
method. We can apply methods to strings using dot notation. This involves writing a dot (.) followed by the method we want to use. For example, the
following code will tell us which character is at position in the string
'Hello'.
In this example, the number ...