I'm looking for a way to merge an object into an array based on a common value. My solution should be dynmic, which causes me a lot of troubles. Here is an example:
I have a multidimensional array (see codebelow). It contains a column called "Währung", which has numeric values.
0: {AGIMENDO Info Objekt 1: "00000000", Beschreibung Kurz: "Test0", Währung: "200.00", __rowNum__: 1}
1: {AGIMENDO Info Objekt 1: "00000001", Beschreibung Kurz: "Update1", Währung: "456.00", __rowNum__: 2}
2: {AGIMENDO Info Objekt 1: "00000002", Beschreibung Kurz: "Test2", Währung: "12.00", __rowNum__: 3}
3: {AGIMENDO Info Objekt 1: "00000003", Beschreibung Kurz: "Test3", Währung: "549153.00", __rowNum__: 4}
4: {AGIMENDO Info Objekt 1: "00000004", Beschreibung Kurz: "Text", Währung: "1.05", __rowNum__: 5}
5: {AGIMENDO Info Objekt 1: "00000005", Beschreibung Kurz: "13.08.11", Währung: "465.00", __rowNum__: 6}
6: {AGIMENDO Info Objekt 1: "00000006", Beschreibung Kurz: "Test21", Währung: "4594.00", __rowNum__: 7}
For each row, I iterated through each cell and assigned a "type" to each cell that contains a numeric/date value. The codebelow shows that array. Now I want to merge these two arrays based on the common value (for the first array it's "währung" and the second array it's "value). I tried using lodash _.map, _.assign etc. but I don't get the output I want.
0: {type: "number", value: "200.00"}
1: {type: "number", value: "456.00"}
2: {type: "number", value: "12.00"}
3: {type: "number", value: "549153.00"}
4: {type: "number", value: "1.05"}
5: {type: "date", value: "13.08.11"}
6: {type: "number", value: "465.00"}
My target output would look like this (for the first row):
> 0:
> AGIMENDO Info Objekt1: "00000000"
> Beschreibung Kurz: "Test0"
> Währung:
> Value : "200.00"
> Type: "number"
How do I achieve this?