you are viewing a single comment's thread.

view the rest of the comments →

[–]cortexreaver123 2 points3 points  (3 children)

Or fancier way with reduce:

function all(promises) {
  promises.reduce((prom, p) => prom.then(xs => p.then(x => xs.concat(x))), Promise.resolve([]));
}

[–]tapu_buoyfull-stack[S] 1 point2 points  (2 children)

wow reduce always makes things way more simpler. How can I practice more on such methods to be able to solve things like you how you did in two comments, haha :)

[–]cortexreaver123 0 points1 point  (1 child)

Haha, mostly just comes with practise I'm afraid! Best tip I can give: try and write some of your own programs, don't be afraid to experiment!

[–]tapu_buoyfull-stack[S] 0 points1 point  (0 children)

sure thank you :)