title: How to check if an el has a class that matches a value in array?
body: <p>I have an array and some <code>path</code> elements. I need to check if the <code>class</code> of a <code>path</code> matches one of the values in my array and if so add a class <code>fadeIn</code> to it, I tried this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var nationList = ["usa", "france", "italy"];
  var foundNations = $.unique(nationList.sort());
  $("path").each(function() {
    for (var i = 0; i &lt; foundNations.length; i++) {
      if ($(this).hasClass(foundNations[i])) {
        $(this).addClass("fadeIn");
      }
    }
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.fadeIn {
    color: red;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;path class="spain"&gt;Spain&lt;/path&gt;
  &lt;path class="italy"&gt;Italy&lt;/path&gt;
  &lt;path class="germany"&gt;Germany&lt;/path&gt;
  &lt;path class="usa"&gt;USA&lt;/path&gt;</code></pre>
  </div>
  </div>
  </p>