So I've come across this problem when trying to eliminate the need for duplicated data.
Say I've got a list of objects. I'm separating them based on a specific category. And 2 objects return the same data within the Open 'category'. I don't necessarily want to remove the data, so I think merging/combining is the best way?
If Open
category, merge all objects. How can I merge objects? I think .concat() is just for arrays. So is this even possible?
...
Open
------
const dupObjects = this.props.response.flight['open'];
// returns objects that look like this...
Object {delta: Array[1], lambda: Array[0], amount: }
Object {delta: Array[1], lambda: Array[0], amount: 200,000} // duplicate lets combine
Object {delta: Array[1], lambda: Array[0], amount: 200,000} // duplicate lets combine
if (category == 'Open'){
// merge objects
const dupObjects = this.props.response.flight['open'];
}
Expected output:
Open:
Delta : Information... Lambda: Information... Amount: $0
Delta : Information... Lambda: Information... Amount: $200,000