title: onclick function not working on JSFiddle but working on CodePen
body: <p>I was working on a Timer code and was facing issue with it and <a href="https://stackoverflow.com/questions/33483485/onclick-unable-to-find-function">posted a question</a> regarding it. After discussion, thanks to @James, I found it was JSFiddle issue.</p>
  
  <p><strong>JSFiddle Link</strong>: <a href="http://jsfiddle.net/RajeshDixit/0gvfc5yy/4/" rel="nofollow noreferrer">http://jsfiddle.net/RajeshDixit/0gvfc5yy/4/</a></p>
  
  <p><strong>CodePen Link</strong>: <a href="http://codepen.io/rajesh_dixit/pen/RWBowQ" rel="nofollow noreferrer">http://codepen.io/rajesh_dixit/pen/RWBowQ</a></p>
  
  <p>When you run it on JSFiddle, you will get following error</p>
  
  <blockquote>
    <p>Uncaught ReferenceError: startTimer is not defined</p>
  </blockquote>
  
  <p>But works fine on CodePen and in snippet below.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function timer() {
      var time = {
          sec: 00,
          min: 00,
          hr: 00
      }
      var max = 59;
      var interval = null;
  
      function update(str) {
          time[str]++;
          time[str] = time[str] % 60;
          if (time[str] == 0) {
              str == "sec" ? update("min") : update("hr");
          }
          print(str);
      }
  
      function print(str) {
          var _time = time[str].toString().length == 1 ? "0" + time[str] : time[str];
          document.getElementById("lbl" + str).innerHTML = _time;
      }
  
      function initInterval() {
          interval = setInterval(function () {
              update("sec");
          }, 1000);
      }
  
      function stopTimer() {
          clearInterval(interval);
      }
  
      return {
          'init': initInterval,
              'stop': stopTimer
      }
  };
  
  var time = new timer();
  
  function startTimer() {
      time.init();
  }
  
  function endTimer() {
      time.stop();
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div&gt; &lt;span id="lblhr"&gt;00&lt;/span&gt;
  : &lt;span id="lblmin"&gt;00&lt;/span&gt;
  : &lt;span id="lblsec"&gt;00&lt;/span&gt;
  
  &lt;/div&gt;
  &lt;button onclick="startTimer()"&gt;Start&lt;/button&gt;
  &lt;button onclick="endTimer()"&gt;Stop&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>