Within my Angular Application, I am receiving an array of objects from an API:
"register":[
{
"club": 8,
"players": 100,
"officials": 10
},
{
"male": 7,
"female": 2,
"other": 1
},
{
"Brazil": 5,
"France": 1,
"Italy": 2,
"England": 2
}
]
I want to specifically display the value for 'England' in the console which is located in the third object. I attempted looping through the array like this:
let country = data['register'].map(data => data.England)
console.log(country) // Output: [undefined, undefined, 2]
The 'undefined' values seem to be generated by the first two objects.
Is there a way to iterate through only the third object and retrieve the figure for 'England' without having the initial 'undefined' values appear?
Note:
'Data' originates from the API I have connected to in the .ts file, containing all the information gathered from the API call.