Looking for a simple JavaScript code for a Vue application that will split the string into an array and check if any value is present in a different string.
Here's what I have:
let AffiliationString = " This person goes to Stony Brook"
let affiliation = "Stony Brook OR Stony Brook University OR The University of Washington"
let affiliations = affiliation.toLowerCase().split(" or ");
affiliation = affiliations.join(",");
let regexList = [ affiliation ];
let isMatch = regexList.some(rx => rx.test(AffiliationString));
I am trying to determine if any item in the array is found in the "AffiliationString" string.
When attempting this, I encounter the following error:
Uncaught (in promise) TypeError: rx.test is not a function
I have explored various examples on StackOverflow demonstrating how to check if a value exists in an array, but not the reverse. I am referencing: javascript - match regular expression against the array of items
This task is being carried out within a Vue project utilizing:
"eslint": "6.7.2",
Should I approach this by looping through each value in the array?
Thank you for your assistance.