I am facing an issue with finding the indexes of phrases that contain a specific keyword in an array.
var possibleValues=["contacts","delete","new contact","add","display"];
The user input can vary, it could be "contacts" or even "how to create a contact?". My function needs to return the indexes of phrases in the array that include the keyword 'contact'. I have attempted a logic but haven't been successful so far. Here is what I have done:
var indexes = [];
for (i = 0; i < possibleValues.length; i++) {
if (arr[i].indexOf(userinput) != -1 || userinput.indexOf(arr[i])!=-1) {
indexes.push(i);
}
}
If anyone has some insights on how to solve this issue, your help would be greatly appreciated!