title: Javascript if value is in array else in next array
body: <p>I have found a few posts on here with similar questions but not entirely the same as what I am trying. I am currently using a simple if statement that checks the data the user enters then checks to see if it starts with a number of different values. I am doing this with the following:</p>
  
  <pre><code>var value = string;
  var value = value.toLowerCase();
  country = "NONE";
  county = "NONE";
  
  if (value.indexOf('ba1 ') == 0 || value.indexOf('ba2 ') == 0 || value.indexOf('ba3 ') == 0) { //CHECK AVON (MAINLAND UK) UK.AVON
      country = "UK";
      county = "UK.AVON";
  } else if(value.indexOf('lu') == 0){//CHECK BEDFORDSHIRE (MAINLAND UK) UK.BEDS
      country = "UK";
      county = "UK.BEDS";
  }
  </code></pre>
  
  <p>I have about 20-30 different if, else statements that are basically checking the post code entered and finding the county associated. However some of these if statements are incredibly long so I would like to store the values inside an array and then in the if statement simply check <code>value.indexOf()</code> for each of the array values. </p>
  
  <p>So in the above example I would have an array as follows for the statement:</p>
  
  <p><code>var avon = new Array('ba1 ','ba 2','ba3 ');</code></p>
  
  <p>then inside the <code>indexOf()</code> use each value</p>
  
  <p>Would this be possible with minimal script or am I going to need to make a function for this to work? I am ideally wanting to keep the array inside the if statement instead of querying for each array value.</p>