title: Extract city and ZIP code from a string
body: <p>I have a JavaScript string of the format:</p>
  
  <pre><code>"New York City, New York 10024, United States"
  </code></pre>
  
  <p>The String contains city, state, ZIP code, and country information. I'm trying to fetch only the city name and ZIP code from the string but currently only being able to fetch the city name from the string.</p>
  
  <p><strong>JavaScript Code</strong>:</p>
  
  <pre><code>var sampleLocation = "New York City, New York 10024, United States";
  var resLocation = sampleLocation.split(",");
  console.log(resLocation);
  console.log(resLocation[0].replace( /,/g, "" )); 
  </code></pre>
  
  <p><strong>Output</strong>:</p>
  
  <pre><code>["New York City", " New York 10024", " United States"]
  New York City
  </code></pre>
  
  <p>I can't figure out how to extract the city and ZIP code efficiently. Is there a way to select the last six characters of an array element?</p>