let cities = [ {name: 'Los Angeles', population: 3792621}, {name: 'New York', population: 8175133}, {name: 'Chicago', population: 2695598}, {name: 'Houston', population: 2099451}, {name: 'Philadelphia', population: 1526006} ]; let bigCities = cities.filter(city => city.population > 3000000); console.log(bigCities); /* ES5 let bigCities = cities.filter(function (e) { return e.population > 3000000; }); */ Code language: JavaScript (javascript)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter