title: Chrome Extension: How do I get current tabs title and assign string to variable?
body: <p>I am trying to get the title of the current tab in chrome using an extension and then assigning the returned string to a variable. I managed to get the title using <code>tabs[0].title</code> but I haven't been able to assign that title to a new string variable.</p>
  
  <p>This is the code:</p>
  
  <pre><code>var address;
  
  chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
      var tab = tabs[0];
      var title = tab.title;
  
      console.log("Title: " + title);
      address = title;
  });
  
  console.log("Address:" + address);
  </code></pre>
  
  <p>The line <code>console.log("Title: " + title);</code> shows that <code>tab.title</code> is working as expected, however, when I try to assign the title string to a new variable (<code>address</code>) it is not working shown when the line <code>console.log("Address:" + address);</code> returns <code>"Address:Undefined"</code>.</p>
  
  <p>I have also tried creating the variable <code>address</code> as an empty string in the first line. This looks like: <code>var address = new String();</code></p>
  
  <p>I have looked on here and looked at the documentation and couldn't find an answer to the problem I am having.</p>