String contains another string [duplicate]

Solution 1:

You can use .indexOf():

if(str.indexOf(substr) > -1) {

}