So, I'm writing code to search for zip codes entered by the user , the code will then state what the County is, if it's valid or state that the county is invalid (within one state). Funny thing is, it works , one the first line only, the second line isn't being processed and I'm not sure what I'm doing wrong. I checked online and I seem to match the examples I'm seeing. I will show the code below:
function boroughCheck () {
var n = prompt("Enter a zip code", " ");
var entered = "Borough located:";
if( n == "10451"||"10452"||"10453"||"10454"||"10455"||"10456"||"10457"||"10458"||"10459"||"10460"||"10461"||"10462"||"10463"||"10464"||"10465"||"10466"||"10467"||"10468"||"10469"||"10470"||"10471"){
alert(entered + " Bronx ");
}
else if( n == "11201"||"11202"||"11203"||"11204"||"11205"||"11206"||"11207"||"11208"||"11209"||"11210"||"11211"||"11212"||"11213"||"11214"||"11215"||"11216"||"11217"||"11218"||"11219"||"11220"||"11221"||"11222"||"11223"||"11224"||"11225"||"11226"|"11227"||"11228"||"11229"||"11230"||"11231"||"11232"|"11233"||"11234"||"11235"|"11236"||"11237"||"11238"||"11239"||"11241"||"11242"||"11243"||"11245"||"11247"||"11249"||"11251"||"11252"||"11256"){
alert(entered + " Brooklyn ");
}
else
{
alert(" - Invalid Zip Code")}
}
boroughCheck();
So, what am I doing wrong in this code that makes the first "if" statement run, but not the second "else if " statement . Any zip code I enter is being shown as "Bronx" even if it matches what I've entered in for the Brooklyn area ? Any ideas ?