title: What is the scope of this global / function variable?
body: <p>In the following code, shouldn't x be considered a global variable?  Thus, when it gets to the console.log line x it should have the value of "World".  However, when I run this code it logs "Hello undefined".  `</p>
  
  <pre><code>let x = "World";
  
  function sayHello(x) {
      console.log("Hello ", x);
  }
  
  sayHello();
  </code></pre>
  
  <p>But when I change the parameter to y, it then works as I expected, logging "Hello World.</p>
  
  <pre><code>let x = "World";
  
  function sayHello(y) {
      console.log("Hello ", x);
  }
  
  sayHello();
  </code></pre>
  
  <p>Can someone explain what is going on here?</p>
  
  <p>thanks</p>