title: Global variable doesn't keep value after being changed in node
body: <p>My issue is that my code is assigning champName to a different value inside function in the readfile call. However, after the call is over, champName does not retain that value even though it is declared globally for that function. How do I fix this?</p>
  
  <p>The code below is what I have right now. Previously I tried to have the for loop outside of the function, but then I would get errors about <code>cannot read property 'length' of undefined</code> even though undefined should be champsJson, which was previously defined, meaning that champsJson doesn't get updated outside of that method.</p>
  
  <pre><code>//This function takes in a champId (number) and returns the appropriate 
  //string that is associated with that champId
  function decipherChamp(champId) {
      //Local variables
      var champName = 'This should never print';
      var champsJson = ''
  
      //Reads champions.json into rawData
      fs.readFile('./commands/lol/champions.json', 'utf8', function (err, data) {
          if (err)
              throw err;
          champsJson = JSON.parse(data);
          for (let i = 0; i &lt; champsJson.length; i++) {
              if (champsJson[i].championId == champId) {
                  champName = champsJson[i].championName;
                  console.log("champName inside fn: " + champName)
              }
          }
      });
      console.log("champName before return: " + champName)
      return champName
  }    
  </code></pre>
  
  <p>I've added <code>console.log("champName before return: " + champName)</code> to see what champName is right before printing, and it prints <code>This should never print</code>, the initialized value, instead of the expected result, <code>&lt;The Champion's Name&gt;</code></p>
  
  <p>Observed output:</p>
  
  <p><code>Running command lol:currgame.
  champName before return: This should never print
  champName inside fn: Brand
  champName before return: This should never print
  champName inside fn: Graves
  champName before return: This should never print
  champName inside fn: Tristana
  champName before return: This should never print
  champName inside fn: Jax
  champName before return: This should never print
  champName inside fn: Malzahar
  champName before return: This should never print
  champName inside fn: Thresh
  champName before return: This should never print
  champName inside fn: Galio
  champName before return: This should never print
  champName inside fn: Kai'Sa
  champName before return: This should never print
  champName inside fn: Trundle
  champName before return: This should never print
  champName inside fn: Kennen</code></p>
  
  <p>Expected output:</p>
  
  <p><code>Running command lol:currgame.
  champName before return: Brand
  champName inside fn: Brand
  champName before return: Graves
  champName inside fn: Graves
  champName before return: Tristana
  ...</code></p>
  
  <p>I also noticed that it prints the champName before the return before the inside of the function result, which makes me believe that it is an error with my understanding of async in node, but I'm not sure.</p>