This course will be retired on October 31, 2026.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Introducing ES2015!
You have completed Introducing ES2015!
Preview
So long String.indexOf()! Now we can get a boolean value if a string contains our search text.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Well thankfully we can,
with the new startsWith, endsWith and
0:00
includes methods for a searching strings,
so first let's take a look at a couple of
0:00
different ways we could determine if
a string started with a particular value.
0:04
And if you're following along
you'll need to launch the latest
0:09
workspace for this video.
0:11
I'll open up the file starts-with.js
in the first console.log we have
0:13
a regular expression,
testing this during to search string.
0:18
The next console.log checks to
see if the strings zero index
0:22
matches the string a-really.
0:27
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up