title: Socket.io send data to global variable
body: <p>I'm using socket.io to make a multiplayer game and I'm having an issue where everything the server returns is being contained inside of the function.
  I'm trying to return the data to a global variable on the client side. </p>
  
  <pre><code>&lt;script&gt;
      let test = "no";
      let socket = io();
      socket.on('player',function(data){
          test =  data;
      });
      console.log(test); // says no instead of yes     
  &lt;/script&gt;
  </code></pre>