Array.reduce()

Learn `reduce` once and for all

The reduce method confuses a lot of people. There are numerous Twitter threads lamenting its difficulty, some going so far as to say "Never use it!" I'm not one to say that.

I think reduce is the most powerful array method there is. In fact, I think you can learn reduce so well, that you will realize it's the only method you really need.

You can do literally anything to an array with it. Every array method can be accomplished using reduce, and we're going to prove that in this course. Seriously, check out the "Course Strategy" down below.

I think that once you learn and master reduce, where you're comfortable enough with it to implement the other array methods with it, you'll have more than enough knowledge and skill to decide for yourself whether or not to use reduce. Let's make these decisions from a place of confidence, not a place of fear.

Course Rundown

I am so excited for you and this course. Every lesson contains a full written explanation of the content. This isn't just a verbatim transcript of a video. Think of it like a full blog post per lesson. In addition to the written content, almost all of the lessons have one or more videos that go with them as well. Whether you like written or visual content, I've got you covered.

This course is primarily exercise driven. After an intro lesson or two to introduce reduce conceptually, we're going to get into a lot exercises.

The way I learned reduce is the way I'm going to teach you: we will implement a whole lot of functions, including many of the Array.prototype methods, using reduce. Functions like sum and product, and methods like map, filter, every, includes, etc. Repetition will hopefully drive the concept home.

We're going to do this using "test driven development" (TDD). Each lesson, we will write tests to prove that our functions work as we expect. My hope is that the work of writing and passing tests will help you see more clearly how the reducer function works with each iteration.

Also, in addition to doing each exercise with reduce, we will also implement each exercise using for loops. My hope is that this will also help drive the concept home by creating a mental map between the declarative and imperative versions of the code.

Sample Lesson

Want to get a feel for what a lesson might be like? Check out the find lesson from this course.

Price: 5-50 USD. You choose!
Get the course!

Lessons

  1. `Reduce` Conceptually
  2. The `reduce` API
  3. Build `reduce` from scratch
  4. My approach
  5. Exercise: `sum` and `product`
  6. Exercise: `min` and `max`
  7. Exercise: `join`
  8. Exercise: `indexOf`
  9. Exercise: `find`
  10. Exercise: `includes`
  11. Exercise: `every` and `some`
  12. Exercise: `concat`
  13. Exercise: `map` and `filter`
  14. Practical Use: `counts`
  15. Practical Use: `indexByKey`
  16. Practical Use: `groupBy`