title: get ip address by domain with dns.lookup() node.js
body: <p>Referring to <a href="https://nodejs.org/api/dns.html#dns_dns_lookup_hostname_options_callback" rel="noreferrer">this documentation</a> I am getting the ip address from domain name inside <code>console.log</code>
  the code looks like so:</p>
  
  <pre><code>const dns = require('dns');
  
  dns.lookup('iana.org', (err, address, family) =&gt; {
    console.log('address: %j family: IPv%s', address, family);
  });
  </code></pre>
  
  <p>Output of console.log is fine.
  However I can't get address outside that scope. The return statement of the <code>dns.lookup</code> function is an object.</p>
  
  <p>What I've tried so far:</p>
  
  <pre><code>const ipAddress = dns.lookup("www.aWebSiteName.am", (err, address, family) =&gt; {
    if(err) throw err;
    return address;
  });
  
  console.log(ipAddress);
  </code></pre>
  
  <p>I am getting:</p>
  
  <pre><code>GetAddrInfoReqWrap {
    callback: [Function],
    family: 0,
    hostname: 'www.aWebSiteName.am',
    oncomplete: [Function: onlookup] }
  </code></pre>