Flattening an array is nothing but returning only selected items in the form of array .
we can push only the needed value instead of the item . see the example below
const utubers=[{id:1,name:'Test Ed',sal:5000},{id:2,name:'Dev Ed',sal:5000},{id:3,name:'Mr Beast',sal:2000},{id:4,name:'Mr Boss',sal:2000},{id:5,name:'MKBHD',sal:5000}]
const salGt2000ids = utubers.reduce(((tempArray,utuber)=>{
if(utuber.sal>2000){
tempArray.push(utuber.id)
}
return tempArray;
}
),[])
console.log(salGt2000ids);