Now we have a problem which is that we want to check if a string includes substring or not.
Now let's imagine that we have an string like this:
And want to check if this string contains
How to solve this problem?
Solving this problem is easy, especially because there is a function called
includes that does everything for us.
includes() method returns
true if the substring is contained in the string. Otherwise,
false is returned.
Check if a string includes substring
As we said before, we can use
includes to check if a string contains substring or not.
Let's see an example
And when we know the return value from the method (
false), we can write lines of code based on that value.
Thank you for reading
Thank you for reading my blog. 🚀