Answers for "filter in array and create new array javascript"

CSS
0

filter array inside array

//you can do a .map to iterate over the first level array
// and return an object that have all the other things in the array with spred operator
// and add a new property that will be the second level array filtered
arrayTier1.map((item) => {
        return ({...item, arrayTier2: item.arrayTier2.filter(subitem => subitem.value == 2)});
Posted by: Guest on December-12-2021

Code answers related to "filter in array and create new array javascript"

Browse Popular Code Answers by Language