When you search for related words in a general area that are not in strict sequential order, you will have to resort to use a regex pattern that search across multiple words at a time.
"firstword someword anotherword someotherword secondword".match(/\b(?:firstword(?:\W+\w+){1,3}?\W+secondword)\b/g)
// Returns
// ["firstword someword anotherword someotherword secondword"]