from the countries API I want to identify the 10 largests countries, already got the area values of these countries in the largest array but I want to reference the names of those cuntries in the object obtained from the API.
const countriesAPI = 'https://restcountries.com/v2/all'
let area = []
let names = []
let languages = []
let langNames = []
const fetchData = async () => {
try {
const response = await fetch(countriesAPI)
const countries = await response.json()
countries.forEach(country => {
area.push(country.area)
names.push(country.name)
languages.push(country.languages)
})
let areaSorted = area.sort((function(a,b){return b - a}))
let largests = areaSorted.slice(0,10)
console.log(largests)
} catch (err) {
console.error(err)
}
}
fetchData()
this is what I got so far
How can I use the info from the top ten areas to find what cuntries they belong to