filter CODE
The function
filter
filters the array members based on the
getNames
function condition
let myFavoritePlanets = [
    {name: 'Earth', radius: 6371}, 
    {name: 'Jupiter', radius: 69911}, 
    {name: 'Neptune', radius: 24622, moons: ['Triton', 'Thalassa', 'Nereid', 'Proteus', 'Hippocamp', 'Naiad']}
]
let biggerPlanetsNames = myFavoritePlanets.filter(getNames);

function getNames(planet) {
  return planet.radius > 20000
}
console.log(biggerPlanetsNames );
by Valeri Tandilashvili
4 years ago
JavaScript
Array functions
1
Pro tip: use ```triple backticks around text``` to write in code fences