JSFiddle - React, Tailwind, and code Playground
JavaScript
string = "the word tree is in this sentence";
var array = [];
array[0] = "dog";
array[1] = "cat";
array[2] = "bird";
array[3] = "birds can fly";
if( (new RegExp( '\\b' + array.join('\\b|\\b') + '\\b') ).test(string) ){
alert('match');
}
else{
alert('no match');
}