title: Why is my JavaScript hoisted local variable returning undefined but the hoisted global variable is returning blank?
body: <p>As part of my learning JavaScript, I try to write code to demonstrate the concept I am learning; today I'm learning hoisted variables.  Here is the code I wrote:</p>
  
  <pre><code>console.log("A: My name is " + name);   
  
  function happy() {
    console.log ("1: I am " + feeling);   
      var feeling = "happy";
    console.log ("2: I am " + feeling);   
  }
  happy(); 
  
  var name = "Jim";
  console.log("B: My name is " + name);   
  </code></pre>
  
  <p>I expected the following results:</p>
  
  <pre class="lang-none prettyprint-override"><code>A: My name is undefined
  1: I am undefined
  2: I am happy
  B: My name is Jim
  </code></pre>
  
  <p>However, when testing my code at WriteCodeOnline.com and in another sandbox, the first console.log displays <code>A: My name is</code>. I am using a Chrome browser, if that makes a difference.</p>
  
  <p>So, my question is, why does the hoisted local variable within the function return undefined while the hoisted global variable returns a blank?</p>