0 day streak
javascript / beginner
Snippet

Finding Text with String.includes()

The includes() method performs a case-sensitive search to determine whether one string may be found within another string. It is helpful for simple search features or checking user input in web forms.

snippet.js
javascript
1
2
3
4
5
6
const sentence = "Next.js makes web development fast.";
const hasNext = sentence.includes("Next.js");
if (hasNext) {
console.log("Next.js was found!");
}
nextjs
Breakdown
1
sentence.includes("Next.js")
Checks if the text 'Next.js' exists anywhere inside the sentence string.