Your functional toolkit: pipe, curry and memoize
Write three small helpers from Topics 15.1 and 15.3, then use them.
1. pipe(...fns) returns a function that passes a value through every function left to right. With no functions, it returns the value unchanged.
2. multiply is curried: multiply(3)(4) returns 12.
3. toSlug must be built with pipe from the given trim, lower and dashes, so toSlug(" Hello Big World ") returns "hello-big-world".
4. memoize(fn) returns a function that caches results by all its arguments (use JSON.stringify(args) as the key). It must call fn only once per different set of arguments, even when the result is undefined.
What Check tests
piperuns functions left to rightpipe()with no functions returns the value unchangedmultiply(3)(4)is 12toSluggiveshello-big-worldand is built withpipememoizecalls the function once per argument listmemoizealso cachesundefinedresults- No errors
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Your page
Console
Nothing logged yet.