For this, we use the indexOf() method (note the small "i" and big "O"), passing in the string we want to look for.
The method returns the position (or "index") of the first appearance, or -1 if not found.
With searching, case matters . If you want to do a case-insigificant search, you need to do something as shown in the final two examples.
|