title: Hex to rgb converter in javascript
body: <p>I'm trying to make a simple rgb to hex converter and I keep getting stuck with Javascript, what am I doing wrong?
  In html part I made a form which on submit calls convert() function.</p>
  <pre><code>function convert() {
      r = parseInt(document.getElementById('r').value);
      g = parseInt(document.getElementById('g').value);
      b = parseInt(document.getElementById('b').value);
  
      rgb(r, g, b);
      function rgb(r, g, b){
          res = ColorToHex(r) + ColorToHex(g) + ColorToHex(b);
          function ColorToHex(color) {
              if (color &gt; 255) return &quot;FF&quot;;
              else if (color &lt; 0) return &quot;00&quot;;
              else color.toString(16).padStart(2, &quot;0&quot;).toUpperCase();
            }
      }
      document.getElementById('result').innerHTML = res;    
      return false;
  }
  </code></pre>