Sarem Hailemeskel
Sarem Hailemeskel

Reputation: 47

part of if statement on same line don't work/respond on the same line

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

Answers (1)

tpschmidt
tpschmidt

Reputation: 2707

You're explicitly checking for capital What's in your if condition.

Upvotes: 1

Related Questions