title: What exactly is this CompareAmounts function doing? (Analysis)
body: <p>I am analyzing a long JS code but I'm new to JS. Despite my best efforts, I have only been able to analyze around 85% of the code. This function CompareAmounts is still eluding me. This JS is supposed to run on a bank webpage, and I can't understand what this function is doing. Could anyone please point out the functionality to me?</p>
  
  <pre><code>function CompareAmounts(a, b) {
          var c = /^\-/gi;
          var d = "";
          var e = "";
          if (a.match(c)) {
              a = a.replace(c, "");
              a = a.replace(".", "");
              a = a.split(",");
              a[0] = (parseInt(a[0]) - parseInt(b)).toString();
              if (parseInt(a[0]) &lt; 0) {
                  a[0] = (a[0] * -1).toString();
              } else {
                  d = "-";
                  e = "";
              }
          } else {
              a = a.replace(".", "");
              a = a.split(",");
              a[0] = (parseInt(a[0]) + parseInt(b)).toString();
          }
          if (a[0].length &gt; 3) {
              var f = a[0].substr(0, a[0].length - 3);
              var g = a[0].substr(a[0].length - 3, a[0].length);
              a[0] = f + "." + g;
          }
          a = d + a.toString() + e;
          return a;
      }
  </code></pre>