title: Variable is undefined, after giving it to a function
body: <p>I have a function that transforms hex to string. 
  Console then says: "hex is undefined on line 148", which is:
  "hex = hex.toString()". Any reason why this is happening?</p>
  
  <pre><code>function hexToStr(hex) {
      hex = hex.toString();
      var str = '';
      for (var n = 0; n &lt; hex.length; n += 2) {
          str += String.fromCharCode(parseInt(hex.substr(n, 2), 16));
      }
      return str;
  }
  </code></pre>