Question: const cities = [ { name: 'Hilo', population: 46559, island: 'Hawaii' }, { name: 'Urban Honolulu', population: 351554, island: 'Oahu' }, { name: 'Kahului', population:

const cities = [ { name: 'Hilo', population: 46559, island: 'Hawaii' }, { name: 'Urban Honolulu', population: 351554, island: 'Oahu' }, { name: 'Kahului', population: 27938, island: 'Maui' }, { name: 'Kaneohe', population: 34509, island: 'Oahu' }, { name: 'Kapaa', population: 11516, island: 'Kauai' }, ... { name: 'Waipahu', population: 39927, island: 'Oahu' }, ]; 

averagePopulation(data) and biggestAndSmallest(data). Each function takes a parameter formatted like the cities variable above. averagePopulation returns the average population of all passed cities. biggestAndSmallest returns a string indicating the biggest and smallest cities by population.

For example

console.log(averagePopulation(cities, 'Oahu')); // prints: 20346.85714285714 console.log(biggestAndSmallest(cities, 'Oahu')); // prints: Biggest: Urban Honolulu; Smallest: Maunawili console.log(averagePopulation(cities, 'Maui')); // prints: 9390.4375 console.log(biggestAndSmallest(cities, 'Maui')); // prints: Biggest: Kahului; Smallest: Kualapuu 

You cannot use loops. Instead, use Underscore. Hint: consider using the Underscore functions filter(), reduce(), max(), and min().

Another hint: the last line of your biggestAndSmallest function could look like this:

return `Biggest: ${biggest}; Smallest: ${smallest}`; 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!