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.
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.
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
product, and methods like
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.
Want to get a feel for what a lesson might be like? Check out the
find lesson from this course.
- `Reduce` Conceptually
- The `reduce` API
- Build `reduce` from scratch
- My approach
- Exercise: `sum` and `product`
- Exercise: `min` and `max`
- Exercise: `join`
- Exercise: `indexOf`
- Exercise: `find`
- Exercise: `includes`
- Exercise: `every` and `some`
- Exercise: `concat`
- Exercise: `map` and `filter`
- Practical Use: `counts`
- Practical Use: `indexByKey`
- Practical Use: `groupBy`