I have two arrays, which are almost identical in structure, except for one has a property:value pair on every object, and the other doesn't.
Newcastle Array (with clubCode property)
[
{"clubCode": "newcastle-united",
"firstName": "Tim",
"lastName": "Krul",
"position": "gk"},
{"clubCode": "newcastle-united",
"firstName": "Rob",
"lastName": "Elliot",
"position": "gk"}
]
Arsenal Array (without clubCode property)
[
{"firstName": "Petr",
"lastName": "Cech",
"position": "gk",
{"firstName": "David",
"lastName": "Ospina",
"position": "gk"}
]
Is it possible to push() the clubCode property to every object within the Arsenal array, so I don't have to manually add it to every single one?
...so each object starts with "clubCode": "arsenal".
Or if there is any other solution I'd love to hear it.
Any help will be appreciated. Thanks in advance.
$scope.arsenalSquadarray by calling a JSON file, which is that same array. The array is returned asarsenalSquad.data. In my controller, I want to write the necessary code to return every object within that array with the property ofclubCodeand the corresponding value ofarsenal.