title: JavaScript: How to check to see if string contains value in array?
body: <p>I have an array of versions:</p>
  
  <pre><code>var versions = ['xs', 'sm', 'md', 'lg', 'thumbnail'];
  </code></pre>
  
  <p>I want to get all the image stored in this array that do not contain any of these suffixes. Here is an example of the array of images:</p>
  
  <pre><code>{
      "files": [
          "/public/uploads/contentitems/063012A5-60BC-4A4C-AEC2-56B0D5D99EF0/063012A5-60BC-4A4C-AEC2-56B0D5D99EF0_1.png",
          "/public/uploads/contentitems/063012A5-60BC-4A4C-AEC2-56B0D5D99EF0/063012A5-60BC-4A4C-AEC2-56B0D5D99EF0_1_xs.png",
          "/public/uploads/contentitems/063012A5-60BC-4A4C-AEC2-56B0D5D99EF0/063012A5-60BC-4A4C-AEC2-56B0D5D99EF0_1_sm.png",
          "/public/uploads/contentitems/063012A5-60BC-4A4C-AEC2-56B0D5D99EF0/063012A5-60BC-4A4C-AEC2-56B0D5D99EF0_1_md.png",
          "/public/uploads/contentitems/063012A5-60BC-4A4C-AEC2-56B0D5D99EF0/063012A5-60BC-4A4C-AEC2-56B0D5D99EF0_1_lg.png",
          "/public/uploads/contentitems/063012A5-60BC-4A4C-AEC2-56B0D5D99EF0/063012A5-60BC-4A4C-AEC2-56B0D5D99EF0_1_thumbnail.png"
      ]
  }
  </code></pre>
  
  <p>I only want the first item, however, I am getting all of them with my current code:</p>
  
  <pre><code>fs.stat(file, function(err, stat) {
      if (stat &amp;&amp; stat.isDirectory()) {
          // perform directory code here
      } else {
          versions.forEach(function(version) {
              if (file.indexOf(version) != -1) {
                  results.push(file);
              }
          });
      }
  });
  </code></pre>