I have two arrays, slicesRank and slicesCount with the following structure. Each element has id and value, which is an array of 46. Values is composed of date and measurement.
e.g.
sliceRank[0]:
{
id: Catan = rank,
values(Array(46)) : {date, measurement}
}
sliceCount[0]:
{
id: Catan=count,
values(Array(46)) : {date, measurement}
}
What should I do if I want to combine the elements with the same prefix in id names. For example, the first element in this two arrays.
The desired structure would be
{
id: Catan,
values(Array(46)) : {date, count, rank}
}
I tried the following, but the values shows undefined.
for(i = 0; i < slicesRank.length; i++) {
var newElement = {};
newElement['id'] = slicesRank[i].id.replace('=rank', '');
newElement['values'] = {
date: slicesRank[i].date,
rank: slicesRank[i].measurement,
count: slicesCount[i].measurement
};
sliceNew.push(newElement);
};
The structure of slicesRank is like this:


{id: Catan=rank, values(Array(46)) : {date, measurement} }is not valid syntax. It's not clear what the data structure you're working with isslicesRankhere, would that help?