title: Finding common minimum value between two arrays
body: <p>I am working on a problem in Javascript. Finding common minimum value between two arrays. However, I have been told that this might not work on some values. What is the issue?</p>
  
  <pre><code>function cmp(a, b) { return a - b; }
  
  function findMinimum(A, B) {
      var n = A.length;
      var m = B.length;
      A.sort(cmp);
      B.sort(cmp);
      var i = 0;
      for (var k = 0; k &lt; n; k++) {
          if (i &lt; m - 1 &amp;&amp; B[i] &lt; A[k])
              i += 1;
          if (A[k] == B[i])
              return A[k];
      }
      return -1;
  }
  </code></pre>