title: Question about scoping. Why isn't it printing x in the console?
body: <p>I'm kinda confused on global/local scopes. I have the following code:</p>
  <pre><code>var x = 12
  
  function a() {
    console.log(x)
  } //nothing being logged to the console
  
  x = 12
  
  function a() {
    console.log(x)
  } //12 being logged to the console
  </code></pre>
  <p>x is created in the global scope for both scenarios if I'm not mistaken? However, only the second scenario (x = 12) is able to log the value of x to the console. Can someone kindly explain why?</p>
  <p>Thank you.</p>