title: javascript shifting issue (rgb and rgba to hex)
body: <p>I found a RGB to hex converter and I'm trying to make a RGBA to hex converter. The original <code>rgb2hex</code> function works but the new <code>rgba2hex</code> function does not. What am I doing wrong? The rgba function is returning gba, no r.</p>
  
  <pre><code>// convert RGB color data to hex
  function rgb2hex(r, g, b) {
      if (r &gt; 255 || g &gt; 255 || b &gt; 255)
          throw "Invalid color component";
      return ((r &lt;&lt; 16) | (g &lt;&lt; 8) | b).toString(16);
  }
  
  // convert RGBA color data to hex
  function rgba2hex(r, g, b, a) {
      if (r &gt; 255 || g &gt; 255 || b &gt; 255 || a &gt; 255)
          throw "Invalid color component";
      return ((r &lt;&lt; 32) | (g &lt;&lt; 16) | (b &lt;&lt; 8) | a).toString(16);
  }
  </code></pre>
  
  <p>Example:</p>
  
  <pre><code>alert(rgb2hex(255, 155, 055));
  alert(rgba2hex(255, 155, 055, 255));
  </code></pre>
  
  <p>Current output: <code>ff9b2d</code> and  <code>9b2dff</code></p>
  
  <p>Expected output:<code>ff9b2d</code> and  <code>ff9b2dff</code></p>