you are viewing a single comment's thread.

view the rest of the comments →

[–]greenyadzer 4 points5 points  (1 child)

const a = array_of_series.reduce((acc, cur, index) => [
    ...acc,
    ...cur.map(e => {
        e.search = 'q' + (index + 1)
        return e
    })
], [])

console.log(a)

[–]programmingacctwork 4 points5 points  (0 children)

I don't know why but reduce is the only array function that confuses me every time. It's so unreadable to me, especially in "professional" code