I want to show average of population of all the countries. I am trying to create one array from mapped data and then get average. I don't know how to create one array from the data. Or is there other way of doing it?
code:
function getAverage(countries) {
countries.map((country) => {
const countryPopulation = country.population;
console.log(countryPopulation);
return countryPopulation;
});
}

.mapreturns the array you’re looking for. Log that result, not the individualcountryPopulationvalues. Just look at the examples in the documentation.