DEV Community

Cover image for apnacollege
Ali Hamza
Ali Hamza

Posted on

apnacollege

Hello Dev Community! 👋

It is officially Day 17 of my journey to master the MERN stack! Today, I wrapped up the final part of Lecture 5 of Apna College's JavaScript course with Shradha Didi. We focused entirely on the holy trinity of functional array operations: .map(), .filter(), and .reduce().

Up until yesterday, if I wanted to copy or filter an array, I had to create empty arrays and write loop structures to push items manually. Today, I learned how to do it inline like a professional.


🧠 Key Learnings From JS Lecture 5 (Part 3)

The biggest concept today was that .map() and .filter() do not change the original dataset; they return a brand-new array. This is a crucial rule for state management in modern development.

1. The .map() Method

Similar to .forEach(), it loops through every item. However, .map() returns a new array containing the results of whatever operation you perform on each element. It's the standard way to generate UI elements from a data list.

2. The .filter() Method

This method loops through an array and filters out elements based on a condition. If the condition evaluates to true, the item is added to the new filtered array; if false, it gets dropped.

3. The .reduce() Method

This is used when you want to take an entire array of multiple inputs and reduce it down to a single output value (like a total sum or a maximum number). It utilizes an accumulator (which stores the running total) and a current value.


🛠️ What I Actually Code / Practiced

I spent my practice session solving the algorithmic challenges from Shradha Didi’s lecture:

  • The 90+ Marks Filter: Created an array of student marks and used .filter() to instantly generate a clean list containing only scores above 90.
  • The Factorial / Sum Generator: Took an array of sequential numbers from 1 to n and used .reduce() to compute both the total sum and the factorial product of the entire sequence.

Seeing multiple array values condense down into a single precise output or filter dynamically with just two lines of arrow-function logic felt absolutely powerful!


🎯 My Goal for Tomorrow (Day 18 / Lecture 6)

Tomorrow, I am moving to Lecture 6 of the Apna College sequence:

  • Entering the bridge between JavaScript logic and visual design: the DOM (Document Object Model).
  • Learning how to select and dynamically target HTML elements directly using scripts.

💬 Let's Connect!

To the Apna College community: Which method did you find trickier to grasp initially, .filter() or .reduce()? To the senior devs: How often do you chain these three methods together in your data processing pipelines?

My functional array practice scripts are committed and pushed to GitHub!
[Links in the Comments]

Keep learning, keep building! 🚀

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.