title: Is it better to compare strings using toLowerCase or toUpperCase in JavaScript?
body: <p>I'm going through a code review and I'm curious if it's better to convert strings to upper or lower case in JavaScript when attempting to compare them while ignoring case.</p>
  <p>Trivial example:</p>
  <pre class="lang-js prettyprint-override"><code>var firstString = &quot;I might be A different CASE&quot;;
  var secondString = &quot;i might be a different case&quot;;
  var areStringsEqual = firstString.toLowerCase() === secondString.toLowerCase();
  </code></pre>
  <p>or should I do this:</p>
  <pre class="lang-js prettyprint-override"><code>var firstString = &quot;I might be A different CASE&quot;;
  var secondString = &quot;i might be a different case&quot;;
  var areStringsEqual = firstString.toUpperCase() === secondString.toUpperCase();
  </code></pre>
  <p>It seems like either &quot;should&quot; or would work with limited character sets like only English letters, so is one more robust than the other?</p>
  <p>As a note, MSDN recommends normalizing strings to uppercase, but that is for managed code (presumably C# &amp; F# but they have fancy <code>StringComparers</code> and base libraries):</p>
  <p><a href="http://msdn.microsoft.com/en-us/library/bb386042.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb386042.aspx</a></p>