In my quest to identify specific words within a comma-separated log, I have encountered an issue. The current code snippet effectively locates individual words, but struggles to find all three words together in the log.
$log = "Left Side Turn, Left Side Road, No Turn, Left, Right Turn";
var currLog = $("#log").text();
var theName = "Left Side Road"; //target phrase...
var currLogWords = currLog.split(/\b/);
var hits = [];
for (var i = 0; i < currlogWords.length; i++) {
if (theName == currlogWords[i]) {
hits.push(currlogWords[i]);
}
if (hits == 0) { do something } else { do other }