title: Get asynchronous value's return on C2
body: <p>Here is the code I'm using:</p>
  <pre class="lang-js prettyprint-override"><code>const { exec } = require(&quot;child_process&quot;);
  
  exec(&quot;ls -la&quot;, (error, stdout, stderr) =&gt; {
      if (error) {
          console.log(`error: ${error.message}`);
          return;
      }
      if (stderr) {
          console.log(`stderr: ${stderr}`);
          return;
      }
      console.log(`stdout: ${stdout}`);
  });
  </code></pre>
  <p>It returns &quot;0&quot; and then logs in the console the correct result.</p>
  <p>But how to directly <code>return</code> the result instead of <code>console.log</code>?</p>
  <p>Some answers have pointed out how to convert it into a Promise.</p>