i have array of objects need to convert to new array with new property using another list of strings to read the property in javascript.
var output =
[
{Id: '000000CayeAAC', Name: 'KCP13', FTA: 'LOS', FTN: 'M'}
{Id: '000000CayLAAS', Name: 'KCN15', FTA: 'DC', FTN: 'M'}
{Id: '000000CaxXAAS', Name: 'KCA21', FTA: 'AUS', FTN: 'M'}
{Id: '000000CaxCAAS', Name: 'KCZ43', FTA: 'CA', FTN: 'M'}
]
var mypropertylist = ['Name','FTA','FTN'];
i want to new array is like below
var newArray =
[
{value: '000000CayeAAC', concatName: 'KCP13 - LOS - M'}
{value: '000000CayLAAS', concatName: 'KCN15 - DC - M'}
{value: '000000CaxXAAS', concatName: 'KCA21 - AUS - M'}
]
i tried this way
output.map(item=>{
this.newArray = [...this.newArray,
{value:item.Id,
concatName:item.Name + ' - '+item.FTA+ ' - '+item.FTN}];
i got desired output but i want to get dynamically by using mypropertylist
Thanks in Advance!
KCZ43disapear ?