title: Find factors of number and return nth position
body: <p>n and k are inputs, 10, 3 respectively<br />
  Find the factors of n =&gt; 1,2,5,10<br />
  return the Kth value =&gt; 5<br />
  I'm getting undefined.<br />
  Just learning asych/await, that is probaly the issue.<br /></p>
  <p>function pthFactor(n, k) {<br />
  // Write your code here<br />
  getFactors(n,k);<br /></p>
  <pre><code>async function getFactors(n,k) {
      let promise = new Promise((resolve, reject) =&gt; {
          setTimeout(() =&gt; resolve(&quot;done!&quot;),7000)
      });
      if (n === 1 || k === 1) {
          return 1;
      }
      let result = await promise;
      console.log(result);
  
      let factors = [];
      console.log(factors);
      for (let i = 1; i &lt;= n; i++) {
      if (n &gt; 10 ** 15 || k &gt; 10 ** 9) {
          continue;
      }
      if (n % i === 0) {
          factors.push(i);
          console.log(factors);
              if ( factors.length === k) {
                 return factors[k-1]; 
              }
      }
      console.log(factors);
      return 0;
      }
  }
  </code></pre>
  <p>}</p>
  <p>console.log(pthFactor(10, 3));</p>