Challenge 2 and Solution
// -- Challenge 2 -------------------------
// Make a boolean function that says whether
// a given person wrote any of the articles.
// Use the names function you wrote above
// with _.compose and _.contains.
var isAuthor = _.identity; // change this
assertEqual(
false,
isAuthor('New Guy', articles)
);
assertEqual(
true,
isAuthor('Debbie Downer', articles)
);
the solution
var isAuthor = function (name, articles) {
return _.compose(_.contains(name), names)(articles)
}
Later we will a lot more examples where compose
will be very useful.