title: Array reduce function for comparing major.minor.patch strings
body: <p>I came across something weird which I quite did not understand as to why it is working. following code works fine and always return the max version till the patch level. although we are comparing each version string as interger/number. can someone explain me why it is behaving the way it is?</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 versionArr = ['4.2.2','4.2.1','3.1.0','3.2.1','3.0.0'];
  
  console.log(versionArr.reduce((acc,item) =&gt; acc &gt; item?acc:item));</code></pre>
  </div>
  </div>
  </p>