title: Convert RGB to Hex color
body: <p>Below is a function to convert rgb to hex color. But it is not totally correct. With (0, 255, 0) (#00ff00). it return ff00 and so it is not valid color. I need help to modify it to return correct hex value.</p>
  
  <pre><code>function rgbToHex(r, g, b) {
          var rgb = b | (g &lt;&lt; 8) | (r &lt;&lt; 16);
          return rgb.toString(16);
      }
  </code></pre>