I have a long list of roles obtained from a sheet range stored as strings in an array, to give an example the array looks something like this:
arr1 = ["football manager","hockey coach", "fb player","fb coach","footballer"];
and I have another array in which I have a list of words and a classification code
it represents something like the following table.
Table # 2
| Profession | Class |
| ——————–| ————– |
| football | FB01 |
| fb | FB01 |
| hockey | HK01 |
| footballer | FB01 |
I am trying to match the roles of the first array to the professions on the second one and assign a class to each of the roles.
I have been trying to do this by obtaining the index of the matched row:
for(let i in arr1){
arr2.findIndex(s => s.indexOf(arr1[i]) >= 0);
}
But this only works for “footballer” as it is an exact match, I need for all of the partial matches to be classified as well.