I have a variable named title which is having the value "Javascript,XML,XHTML,CSS,Ajax". I need to compare in an if statement if the title equals to the above value some code needs to be run.
I have used
if (title == "Javascript,XML,XHTML,CSS,Ajax"){
} else if (title == " ") {
} else {
}
When the title is null, the code goes to the second else
part and gets the correct result. But when the title is equal to Javascript,XML,XHTML,CSS,Ajax the code goes to the last else
part instead of going to the if
part.
What mistake have I done here? I have checked the upper lower case and also spelling along with the delimiter comma the string is same just as in the variable title. Then why do I not get the correct answer.