Ellimistdev / js-advanced-first-class-functions-practice-lab-online-web-ft-102218

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

First-Class Functions Practice Lab

Objectives

  1. Practice using forEach
  2. Practice using sort
  3. Practice using reduce

Instructions

Be sure to run the tests to get a feel for the types of problems this lab is asking you to solve.

You'll be writing six functions:

  • logDriverNames() — Receives an array of driver objects and logs the name attribute of each driver to the console.
  • logDriversByHometown() — Receives an array of driver objects as the first argument and a location as the second argument. The function logs to the console the name attribute of each driver whose hometown matches the string passed in as the 'location' argument.
  • driversByRevenue() — Receives an array of driver objects and returns a new array of driver objects sorted by their revenue attribute from lowest to highest.
  • driversByName() — Receives an array of driver objects and returns a new array of driver objects sorted by their name attribute from A to Z. Here, you may have to use the String.prototype.localeCompare() method.
  • totalRevenue() — Receives an array of driver objects and returns the sum of the revenue earned by each driver.
  • averageRevenue() — Receives an array of driver objects and returns the average revenue earned by each driver.

Resources

View First-Class Functions Practice Lab on Learn.co and start learning to code for free.

About

License:Other


Languages

Language:JavaScript 75.3%Language:HTML 24.7%