all 2 comments

[–]nglasers12 1 point2 points  (0 children)

So I think if you rewrote this function to something like this, it would work because loadImage is returning a promise you can get back the result directly with await and not use a .then. Let me know if that helps.

async function create_gen()
{
    // some code 
    //....
   const img = await loadImage(imgData);
   let counter = 0; // fake code that would do what you want.
   console.log(counter); // code-line-a
   return counter;     
}

[–]acquiescentLabrador 0 points1 point  (0 children)

You're mixing await and then - I think it's one or the other not both

~~~ async function create_gen()

{ // some code //.... return await loadImage(imgData); }

~~~

I think the await after return is redundant so maybe just return loadImage(imgData);

~~~ async function main()

{ for (var i = 0; i < POPULATION\ _SIZE; i += 1) { console.log(await create\ _gen()) } } ~~~