You can use Array.find or Array.some
find returns "dog" which is not undefined (so truthy) if dog is next to cat.
some will return true if dog, cat are found and false if not
Since your comments show you wanted a true/false function, I made you one.
const textArray = ['bird', 'dog', 'cat', 'snake', 'rabbit', 'ox', 'sheep', 'tiger'];
const areAdjacent = (word1, word2, arr) => arr
.some((word, i, arr) => word===word1 && arr[i+1] === word2);
console.log(areAdjacent("dog","cat",textArray))
console.log(areAdjacent("tiger","bird",textArray))
Using Pilchard's example
const textArray = ['bird', 'dog', 'cat', 'snake', 'rabbit', 'ox', 'sheep', 'tiger'];
const areAdjacent = (word1, word2, arr) => arr
.some((word, i, {[i+1]: nextWord}) => word === word1 && nextWord === word2);
console.log(areAdjacent("dog", "cat", textArray))
console.log(areAdjacent("tiger", "bird", textArray))
for(let i; i < ...)so you can doi + 1.forEach(), which passes the index to the callback.return..find()or.findIndex()then.some()