Learn how to find out if a given string is in a different string in JavaScript in this quick and easy tutorial.
First, let’s define the two strings as follows:
const string = "this is a sample string!";
const search_term = "ring";
To find out if string
contains search_term
, perform the following:
if string.includes(search_term) {
// search term was found
}
That’s all there is to it!
Love our articles? HostM offers professional and helpful web hosting services with unlimited features and renewal rates that actually match our advertised rates.
From $2.48/mo
We can help you move your
email and websites as desired.