I'm working on a chatbot in Javascript, and I have a variable called "target", which is the variable that will contain what the user says in chat, and an array called "doingGood":
let doingGood = ["good", "great", "amazing", "awesome"];
What I want to do, is I want to make an if statement that will do something if the target variable is equal to a string that's in the doingGood array. For example, if target is equal to good, great, amazing, or awesome, do something. I've looked around on the internet, but I'm stumped and can't seem to find an answer. Help would be appreciated, thanks!
EDIT: The question is the same, but I tried the methods that they suggested there and they didn't seem to work. When I tried if (variable.target === doingGood)
, it gave me an error saying "variable is not defined."
No comments:
Post a Comment