Because that is not how
if...else
block works. An if else block (with complex expressions) requires you to use AND operator (which you are) along with different expressions or variable or statements that resolve to boolean value (
true
or
false
). Your code does not follow the guidelines.
I will take the first conditional block, and explain what went wrong there.
if (textinput=="Adelaide" || "Adelaide, Australia" || "Adelaide Australia" || "Adelaide, South Australia, Australia")
Now in the above code block, you are using only one expression to determine the value. Rest of the expressions (literals) are just literals, however the OP operators, constant literals and this expression... They make your first expression to be
true
,
always[
^].
A solution to this is that you change your literals into same expression to check whether they are the values or not.
if (textinput=="Adelaide" ||
textinput=="Adelaide, Australia" ||
textinput=="Adelaide Australia" ||
textinput=="Adelaide, South Australia, Australia")
Now if you would run this code, you would find out that the code indeed works. If there is a match, it would show the results; true. Otherwise it would resolve to be false and the code would move to next stage; false.
Go to this JSFiddle to see a live example of this[
^].
Listen, we are not here to criticize, but to help. Our answers depend on your question; ask a good question to get a good answer, ask stupid question to get a stupid response.