DEV Community

Discussion on: Functional vs Imperative Patterns in JavaScript

Collapse
 
joelnet profile image
JavaScript Joel • Edited

I agree with you about that example being easier to read. I would still prefer consistency in the app and ban all for loops in favor of map reduce and filter.

You could also break the one liner down a bit to help with readability and reusability.

const serialFetch = (promise, url) => promise.then(() => fetch(url))
await urls.reduce(serialFetch, Promise.resolve())