title: can't get JS to correctly evaluate two identical strings
body: <p>I can see in the log that there are multiple matches during the loop but it's only returning true (and adding the file to the array) on the last iteration. 'typeof' is telling me they are all strings and they look identical in the console. can't figure what would make JS not see them as identical. </p>
  
  <p>Would spaces or square brackets cause problems?</p>
  
  <pre><code>var name = file.split('.');
  for (l=0;l&lt;d.length;l++)
  {
    var n = d[l].split('.');
    var r = n[0].replace(/\[\d\]$/,''); //chop off last bracket in file name
  
    // tells me both variables are strings
    console.log('r is a: ' + (typeof r) + ' name is a: ' + (typeof name[0]));
  
    if(r &amp;&amp; r == name[0])
    {
      count_array.push(r);
      console.log('&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;' + r + ' added to array');
    }
  }
  </code></pre>
  
  <p>Thx!</p>