- Practice using forEach
- Practice using sort
- Practice using reduce
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 ofdriver
objects and logs thename
attribute of eachdriver
to the console.logDriversByHometown()
— Receives an array ofdriver
objects as the first argument and a location as the second argument. The function logs to the console thename
attribute of eachdriver
whose hometown matches the string passed in as the 'location' argument.driversByRevenue()
— Receives an array ofdriver
objects and returns a new array ofdriver
objects sorted by theirrevenue
attribute from lowest to highest.driversByName()
— Receives an array ofdriver
objects and returns a new array ofdriver
objects sorted by theirname
attribute from A to Z. Here, you may have to use theString.prototype.localeCompare()
method.totalRevenue()
— Receives an array ofdriver
objects and returns the sum of the revenue earned by each driver.averageRevenue()
— Receives an array ofdriver
objects and returns the average revenue earned by each driver.
View First-Class Functions Practice Lab on Learn.co and start learning to code for free.