title: How can I return value from setInterval function?
body: <p>I want to get status from async function but it always return status undefined and than it goes to function that contains  return status; </p>
  
  <p>main.js</p>
  
  <pre><code> let status = addData(firstname, lastname, age, sex);
   console.log(status);
  </code></pre>
  
  <p>data.js</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>static async addData(firstname, lastname, age, sex) {
    try {
  
      let txdata = await data.dataentry(firstname, lastname, age, sex);
  
      let count = 0;
      let intervalId = setInterval(async() =&gt; {
        let status = await data.entryStatus(txdata);
        logger.info("status %o", status);
  
  
        if (status = true) {
          clearInterval(intervalId);
          return status;
        } else {
          count++;
          if (count &gt; 4) {
            clearInterval(intervalId);
            throw createError();
          }
        }
      }, 500);
  
    } catch (err) {
      throw createError();
    }
  }</code></pre>
  </div>
  </div>
  </p>