you can use indexOf for this
var a="how are you";
if (a.indexOf('are') > -1) {
return true;
} else {
return false;
}
Edit: This is an old answer that keeps getting up votes every once in a while so I thought I should clarify that in the above code, the if
clause is not required at all because the expression itself is a boolean. Here is a better version of it which you should use,
var a="how are you";
return a.indexOf('are') > -1;
Update in ECMAScript2016:
var a="how are you";
return a.includes('are'); //true