I need to compare the word from the string in jQuery. In short each word is in the string then match should be true, otherwise not. It doesn't matter what sequence.
For example if I have the sentence: I need to Visit W3Schools
If I search need w3school
==> Match
If I search need go w3school
==> Not Match
If I search w3schools visit
==> Match
If I search need go
==> Not Match
It can be multiple words like 1, 2 or more than 2.
I used
var keyword = "I need to Visit W3Schools";
if(keyword.indexOf('need w3school') != -1){
console.log('Found');
}else{
console.log('Not Found');
}
But it works only subsequent word not other case "w3schools visit".