Reputation: 47
To clarify the code functions partially, for example "hey" and "hello" will get a respond "hey' but moving to the next line of code "what's your name" don't get a response but all the other "messages" in that line will get a response. There is a problem with the if statement i couldn't figure out. is there a limit to which you can use an 'or' operator on the same line when working with if statements? thanks in advance
function getResponse(message, callback){
console.log("{ User: " + message + " ||| " + " Response: " + "#callback tracker" + "}" );
if (message == "hey" || message == "hello"){
callback("hey")
}else if (message == "What's your name" || message == "what name" || message == "your name" || message == "name" || message == "what was your name again"){
callback("Jarvis");
}else if (message == "What's up" || message == "what's good" || message == "what's happening" || message == "What's the word"){
callback("not much")
}else {
callback("What do you mean by " + message)
}
}
Upvotes: 1
Views: 21
Reputation: 2707
You're explicitly checking for capital What's
in your if condition.
Upvotes: 1