I have object:
data = {
"usa": {
"a": {
"min": 1,
"max": 2,
"avg": 1.5
},
"b": {
"min": 3,
"max": 5,
"avg": 4
}
},
"canada": {
"c": {
"min": 1,
"max": 2,
"avg": 1.5
}
}
}
I would like receive all max values from second dimension, for example:
function getMaxValues(country: string): number[] {
const maxValues: number[] = data[country]???
return maxValues;
}
I any better way than iterate over this object and collect results? In other languages are special functions for this. I don't want use iteration because this object is very large and usually specific functions for this are more efficient.