ES6: Finde ein Objekt in einem Array anhand einer seiner Eigenschaften

Ich versuche herauszufinden, wie das in ES6 geht ...

Ich habe dieses Array von Objekten ..

const originalData=[
{"investor": "Sue", "value": 5, "investment": "stocks"},
{"investor": "Rob", "value": 15, "investment": "options"},
{"investor": "Sue", "value": 25, "investment": "savings"},
{"investor": "Rob", "value": 15, "investment": "savings"},
{"investor": "Sue", "value": 2, "investment": "stocks"},
{"investor": "Liz", "value": 85, "investment": "options"},
{"investor": "Liz", "value": 16, "investment": "options"}
];

.. und diese neue Reihe von Objekten, bei denen ich den Gesamtwert der Investitionstypen (Aktien, Optionen, Ersparnisse) jeder Person addieren möchte ..

const newData = [
{"investor":"Sue", "stocks": 0, "options": 0, "savings": 0},
{"investor":"Rob", "stocks": 0, "options": 0, "savings": 0},
{"investor":"Liz", "stocks": 0, "options": 0, "savings": 0}
];

Ich durchlaufe originalData und speichere jede Eigenschaft des "aktuellen Objekts" in einem let ..

for (let obj of originalData) {
   let currinvestor = obj.investor;
   let currinvestment = obj.investment;
   let currvalue = obj.value;

   ..but here I want to find the obect in newData that has the property = currinvestor (for the "investor" key)
   ...then add that investment type's (currinvestment) value (currvalue) 
}

Antworten auf die Frage(2)

Ihre Antwort auf die Frage