We say a language has "first-class functions" if it supports functions being passed as input or output values of other functions. JS has this feature, and JavaScripters take advantage of it all the time - e.g. it's what allows us to pass a callback function as an input parameter for another function. It's also possible to have a function as a return value. A function which either takes or returns another function is called a "higher-order function".
- Run the tests in
filterMapReduce.test.js
with the commandnode filterMapReduce.test.js
- tests should be failing - Work through the
TODO
s infilterMapReduce.js
to write recursive implementations of all three functions- To move away from the object-oriented method-calling mindset to a functional mindset, use the helper functions
head
,tail
, andcount
defined inarrayHelpers.js
- Run the tests again - most should now be passing
- To move away from the object-oriented method-calling mindset to a functional mindset, use the helper functions
- Work through the
TODO
s infilterMapReduce.test.js
to write applications of these functions that get the remaining tests to pass - Compare your implementations with those of your partner/group and discuss