title: How to see account address in another function in Javasript
body: <p>The account address is getting displayed on the console properly when initializing but showing undefined when calling console.log(account) from other functions. Here is my code.</p>
  <pre><code>var account;
  window.addEventListener('load', async () =&gt; {
      if (window.ethereum) {
          window.web3 = new Web3(ethereum);
  
          ethereum.autoRefreshOnNetworkChange = false;
  
          const accounts = await ethereum.enable();
          account = accounts[0];
          console.log(account); //here the account working properly.
      }
  });
  
  var contractaddress = '0x26708Df214A65Dda444E61266642e6650F4e8923';
  
  function get_request_details() {
      console.log(account); //here it is showing undefined
  }
  window.onload = get_request_details;
  </code></pre>