L
L
lex2018-09-30 13:26:29
JavaScript
lex, 2018-09-30 13:26:29

How to correctly pass the array and enter a new field with an array?

result.map((item, index) => {
    if(item.detailArticle === result[index++].detailArticle){
        return {
            id: item.makerId,
            detailBrand: item.maker,
            detailArticle: item.number,
            detailName: item.description,
            offers: result.map((itm) => {
                if(item.makerId === itm.makerId) {
                    return itm.description
                }
            })
        }
    }
}))

help with a simple advice on how to go through the array of objects as correctly and quickly as possible, if the field matches, write all such objects in the offers field of the new object, that is, how to collect everything into one

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question