Functional Programming - Apply Functional Programming to Convert Strings to URL Slugs

Hello fCC family, what does it mean when the lesson says “Recall that map and filter are special cases of reduce”

Your code so far

// Only change code below this line
function urlSlug(title) {


}
// Only change code above this line
urlSlug("A Mind Needs Books Like A Sword Needs A Whetstone");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edg/107.0.1418.35

Challenge: Functional Programming - Apply Functional Programming to Convert Strings to URL Slugs

Link to the challenge:

they are referring to the earlier lesson on reduce here
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/functional-programming/use-the-reduce-method-to-analyze-data

If you re-read it, notice it says:

The reduce method allows for more general forms of array processing, and it’s possible to show that both filter and map can be derived as special applications of reduce .

Therefore both map and filter are just simplified versions of reduce (you can use reduce to do everything they do plus more)

Ok i see what you mean, it does do both. Im gonna keep that in mind, thank you!

1 Like