title: jQuery global variable undefined
body: <p>I am trying to read the enteredValue variable  outside the function but the value outside the function remains undefined:</p>
  
  <pre><code>var enteredValue;
  
  $("input").on("keydown",function search(e) {
      if(e.keyCode == 13) {
          alert($(this).val());
          enteredValue = $(this).val().trim().toUpperCase()
          console.log("Code inside: " + enteredValue); //value is read
      }
  });
  
  console.log("Code outside : " + enteredValue); //value undefined
  </code></pre>
  
  <p>Can you please tell me what I'm doing wrong?</p>