title: What is 32-bit integer in JavaScript?
body: <p>I was doing some coding challenges and encountered something I am not too familiar with. I am more curious to learn what it is and why it is there.</p>
  <p>The prompt is pretty straightforward:</p>
  <blockquote>
  <p>Given a <strong>32-bit signed integer</strong>, reverse digits of an integer.</p>
  </blockquote>
  <pre><code>Example:
  Input: -123
  Output: -321
  
  Example:    
  Input: 120
  Output: 21
  
  Assume we are dealing with an environment which could only hold integers within the 32-bit signed integer range. For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows.
  </code></pre>
  <p>I came up with this.</p>
  <pre><code>var reverse = function(x) {
      var isNegative = false;
      if(x &lt; 0){
          isNegative = true;
          x *= -1;
      };
      var reverseX = parseInt(String(x).split('').reverse((a,b) =&gt; a - b).join(''));
      if(reverseX &gt; Math.pow(2,32)){
        return 0;
      }
      if(isNegative){
          return -1 * reverseX
      } else {
          return reverseX;
      }
  };
  </code></pre>
  <p>However, I am stumped with some of the failing tests:</p>
  <pre><code>Input:
  1563847412
  Output:
  2147483651
  Expected: 0
  </code></pre>
  <p>To my understanding, 32 bit integer is 2^32. What is its significance in JS and what happen if I started going over? (<code>2^32 + 1</code>)</p>
  <p>My second question, if I may ask two, is I &quot;anticipated&quot; if value of <code>reverseX</code> exceeds 2^32, but it is still failing the test.</p>
  <pre><code>if (reverseX &gt; Math.pow(2, 32)) {
    return 0;
  }
  </code></pre>
  <p>How can I appropriately return <code>0</code> when I exceeded 32-bit integer?</p>