title: JS function not returning value properly
body: <p>I am using qz print Api for printing labels.It has its own function (JS) which displays default printer in alert. I want to display printer name in a div. I have achieved till now. My code is below.</p>
  
  <pre><code>function useDefaultPrinter() {
  var printer; 
  if (isLoaded()) {
  // Searches for default printer
  qz.findPrinter();
  window['qzDoneFinding'] = function() {
  // Alert the printer name to user
  printer = qz.getPrinter();
  
  window['qzDoneFinding'] = null;
  defaultFound = true;
  };
      }
  alert(printer);
  return(printer);
  }
  </code></pre>
  
  <p>For displaying HTML</p>
  
  <pre><code>var printer_name = useDefaultPrinter();
  lbDownHtml += "&lt;div&gt;&lt;span&gt;Default printer found: '" + printer_name + "'&lt;/span&gt;";
  lbDownHtml += "&lt;/div&gt;";
  </code></pre>
  
  <p>The problem is that if i dont use alert(printer) in useDefaultPrinter() before return it displays undefined, but if the alert is there like above code it displays undefine in alert but perfect output in html where i have print it. What is the issue? as i dont want to alert (but if i dont use it it shows undefined).</p>