Reputation: 129
I have this Array of items. The problem is I need to join the CertificateNumber
and Ordinal
from all the items and add a new value for each.
So I can have CertificateJoin: AAAAA00
AAAAA is the CertificateNumber
and 00 is the Ordinal
How can I do this?
Upvotes: 0
Views: 28
Reputation: 4464
You can just cycle through your array and put your merged value in a new property, like so:
var items = [{
fieldA: 1,
fieldB: "A"
},
{
fieldA: 2,
fieldB: "B"
}
]
items.forEach(item => item["join"] = item.fieldA + item.fieldB);
console.log(items);
Upvotes: 1