I have two arrays.
First one:
const triggerWord = ["what", "how", "where", "who", "can"];
Second one:
const myArray = query.split(" "); - it is created after splitting the user input in this case called query.
One is a fixed number of strings, that will not change as they are the trigger words. The other array is an input string that has been split into an array, separated by a space.
I am trying to build some sort of control flow that if any of the triggerWords are present within the myArray then it should call a specific function call the questionFunction(). However the else is that is should call the statement function. Here are the functions I have attempted:
#1: Switch Case:
switch (lowercaseMyArray.includes()) {
    case triggerWord[0].toString():
        questionFunction(lowercaseMyArray);
        break;
    case triggerWord[1].toString():
        questionFunction(lowercaseMyArray);
        break;
    case triggerWord[2].toString():
        questionFunction(lowercaseMyArray);
        break;
    case triggerWord[3].toString():
        questionFunction(lowercaseMyArray);
        break;
    default:
       statementFunction(lowercaseMyArray);
#2: If statement
if (lowercaseMyArray.includes(triggerWord[0] || triggerWord[1] || triggerWord[2] || triggerWord[3], 2)) {
    //alert("This is a question");
    questionFunction(lowercaseMyArray);
    //passe onto questionFunction
} else {
    statementFunction(lowercaseMyArray);
    //alert(myArray);
}
#3: Bool and If Statment
var lowercaseMyArrayBool = lowercaseMyArray.includes(triggerWord);
    if (lowercaseMyArrayBool === true) {
        questionFunction(lowercaseMyArray);
    } else {
        statementFunction(lowercaseMyArray);
    }
The idea being that if it contains a trigger word then the input must be a question and therefore treated as such. However if it doesn't contain the trigger words then the input is a statement and must be treated as that.
Any help or pointers will be greatly appreciated.
