title: How to represent number as hexadecimal in JavaScript?
body: <p>I am trying to convert a DEC number to HEX using JavaScript.</p>
  
  <p>The number I am trying to convert is 28.</p>
  
  <p>I have tried using:</p>
  
  <pre><code>function h2d(h) {return parseInt(h,16);}
  </code></pre>
  
  <p>however it returns 40</p>
  
  <p>I have also tried using:</p>
  
  <pre><code>function d2h(d) {return d.toString(16);}
  </code></pre>
  
  <p>however it returns 28</p>
  
  <p>The final result should return 1C but I can't seem to work it out.</p>
  
  <p>Does anyone know where I have gone wrong?</p>