I have an array of people. Each person object has fields for name and age. I want to create a new array by copying the original and adding a new field (country) to each person object. The country value will come from an array of strings. Therefore, the new objects in the array will have fields for name, age, and country. Check out my live example on Plunker here.
`export class App {
index: number =0;
countries: string [] = ['US', 'UK'];
constructor() {
this.persons = [
{'name':'Marvin','age': 12},
{'name':'Carla','age': 15}
];
this.newPersons = this.persons.map(function(person){
return {
name:person.name,
age : person.age
}
});
}
}`