Check out Amazon Advertising for Humans. Now publicly available 🚀

Javascript: String Methods


If you are looking to find a certain character or set of characters in a string you can use the .indexOf method to return the position of the character in integer format. For example

var myName = "My Name is Nick Coughlin"



Will return 11 because that is the position in the string of the letter N which is what we were searching for. You can also search for a set of character such as is.

var myName = "My Name is Nick Coughlin"



You can also use this property to check whether a character or string of characters is inside of a string using this method. If the character or string is not inside of the string the return will be -1

var myName = "My Name is Nick Coughlin"



And therefore we can simply check to see if it is true that the .indexOf is ===-1. If it is then the character you are searching for is not present.


This will return the length of the string. For example:

myname.length is 15


This will select the character at whatever index position you specify in the parentheses:

the letter m


Will capitalize a string.

whole string is capitalized

This can be combined with .charAt to select and capitalize a specific letter. For example:

the letter n is capitalized


This property will return the string starting from the index which is chosen. Essentially slicing off the characters at the front.

2 letters removed from name


Replace a character, or set of characters in a string with another character.

string.replace(searchvalue, newvalue)

Amazon Ad Analytics For Humans

Advertising reports automatically saved and displayed beautifully for powerful insights.
portfolios page sunburst chart