I have two large files containing object arrays, the first containing data like this:
[{
"id": "001",
"word": "abbess",
"def": "(noun) The lady superior of a nunnery",
}, {
"id": "002"
"word": "abbey",
"def": "(noun) The group of buildings which collectively form the dwelling-place of a society of monks or nuns.",
}, (etc...)
The second, data like this:
[{
"meta": {
"term": "abbess",
"part_of_speech": "noun",
"definition": "The lady superior of a nunnery"
}
}, {
"meta": {
"term": "abbey",
"part_of_speech": "noun",
"definition": "The group of buildings which collectively form the dwelling-place of a society of monks or nuns"
}
}, (etc...)
I want to combine these two files so the "meta" information from the second file is added to the corresponding information from the first file, so:
[{
"id": "001",
"word": "abbess",
"def": "(noun) The lady superior of a nunnery",
"meta": {
"term": "abbess",
"part_of_speech": "noun",
"definition": "The lady superior of a nunnery"
}
}, {
"id": "002"
"word": "abbey - (noun) The group of buildings which collectively form the dwelling-place of a society of monks or nuns.",
"def": "(noun) The group of buildings which collectively form the dwelling-place of a society of monks or nuns.",
"meta": {
"term": "abbey",
"part_of_speech": "noun",
"definition": "The group of buildings which collectively form the dwelling-place of a society of monks or nuns"
}
}, (etc...)
Right now, I'm have this code
var newArr = [];
for(var i = 0; i < meta.length; i++) {
newArr.push(words[i]);
newArr.push(meta[i]);
}
that adds the meta objects after the words object, not within. Do I need to loop down another layer to add the meta objects within the words objects, or is there a different method that would work better here, like .concat()?