Day 16 of #100DaysOfCode: Goodbye, For-Loops. 👋 Today I forced myself to stop using for loops. I spent the entire session mastering JavaScript's higher-order array methods: map, filter, and reduce. To make sure I actually understood it, I set a rule: Type everything from memory. No copy-pasting. What I built: A statistics script that takes raw data and processes it in a single flow. map to transform data (doubling numbers). filter to clean data (keeping evens). reduce to crunch data (summing & calculating averages). The Aha Moment: The power of Chaining. Instead of writing 10 lines of loop logic, I can do this: JavaScript const result = numbers .filter(n => n % 2 === 0) .map(n => n * 2) .reduce((acc, n) => acc + n, 0); It reads like a sentence. DSA Update: No DSA today. I wanted to drill these array methods until they became muscle memory. #JavaScript #WebDevelopment #CleanCode #FunctionalProgramming #100DaysOfCode
Mastering JavaScript Array Methods in 100 Days of Code
More Relevant Posts
-
Day 1 – DSA Journey | Arrays 🚀 Today, I solved two classic array problems on LeetCode and focused more on understanding the logic than just getting accepted solutions. ✅ Problems Solved 📌 Two Sum 📌 Median of Two Sorted Arrays 🔹 Two Sum Approach: I used a HashMap (Map in JavaScript) to store previously seen numbers and their indices. For each element, I calculated the subtarget = target - currentValue and checked if it already existed. Why this works: Instead of checking every pair (O(n²)), hashing lets us find the complement in constant time. What I Learned: ✅ Hashing is powerful for lookup-based problems ✅ Always think about reducing nested loops Complexity: ⏱ Time: O(n) 📦 Space: O(n) 🔹 Median of Two Sorted Arrays Approach: This problem was less about coding and more about clear thinking. I used binary search on the smaller array to find the correct partition such that: Left half contains smaller elements Right half contains larger elements Handled edge cases using -Infinity and Infinity to avoid extra conditions. What I Learned: ✅ Binary search is not just for searching elements ✅ Partition logic + edge cases decide correctness ✅ Understanding the math behind the problem is key Complexity: ⏱ Time: O(log(min(n, m))) 📦 Space: O(1) 🧠 Takeaway Some problems are solved by data structures. Some problems are solved by clear thinking. Both matter. On to Day 2 — staying consistent 🔁🚀 #DSA #Arrays #LeetCode #JavaScript #ProblemSolving #DailyCoding #LearningInPublic #SoftwareDeveloper
To view or add a comment, sign in
-
-
✨ 𝗗𝗮𝘆 𝟰 𝗼𝗳 𝗟𝗲𝗮𝗿𝗻𝗶𝗻𝗴 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 🚀 Today I learned about 𝗖𝗼𝗻𝗱𝗶𝘁𝗶𝗼𝗻𝗮𝗹𝘀, 𝗟𝗼𝗼𝗽𝘀, 𝗮𝗻𝗱 𝗢𝗽𝗲𝗿𝗮𝘁𝗼𝗿𝘀 — the core logic that makes programs think and repeat tasks. But what really surprised me was what happens behind the scenes when we compare values. I discovered why floating-point calculations can be unpredictable in JavaScript. 𝗙𝗼𝗿 𝗲𝘅𝗮𝗺𝗽𝗹𝗲: 𝟬.𝟭 + 𝟬.𝟮 !== 𝟬.𝟯 This happens because JavaScript uses binary floating-point representation (IEEE 754), and some decimal numbers can’t be represented exactly in binary. So tiny precision errors appear. It’s fascinating to see that even simple math has deep computer science concepts behind it. Every day I realize: writing code is one thing, understanding it deeply is another. 💪 #JavaScript #100DaysOfCode #WebDevelopment #LearningJourney #ComputerScience
To view or add a comment, sign in
-
-
Headline: Day 2/100: Mastering the Art of Array Transformation ⚡️📊 The Content: Yesterday was about the "where" (Scopes & Closures). Today, I shifted my focus to the "how"—specifically, how we transform data using Higher-Order Functions. I spent today working through challenges involving map(), filter(), and reduce(). While these seem straightforward, the real magic happens when you understand that they don't just change data—they create new data without mutating the original source (Immutability). Today’s Focus: Functional Purity: Learning why keeping our transformation functions "pure" makes our code predictable and easier to debug. The Power of .reduce(): Realizing that almost any array transformation can be rebuilt using reduce. It’s essentially the "Swiss Army Knife" of JavaScript. Declarative vs. Imperative: Moving away from manual for loops and embracing a more declarative style that describes what I want to happen, not just how to loop. Key Takeaway: Code is read much more often than it is written. Using these transformation methods makes my code more expressive and readable for the next developer (which is often "Future Me"). One step closer to that JS Hero status! 🛠️🔥 ANS: False #JavaScript #100DaysOfCode #Coddy #WebDevelopment #FunctionalProgramming #CodingJourney #SoftwareEngineer
To view or add a comment, sign in
-
-
Data Structures & String Magic Today was all about how we store and manipulate data in JavaScript. I moved beyond simple variables and explored the power of Strings and Objects. It’s fascinating to see how similar Strings and Arrays can be, yet how unique they are in their behavior! My Learning Milestones Today: String Mastery: Explored slice, join, concat, and the importance of case normalization (toLowerCase/toUpperCase) for comparisons. The "Reverse" Challenge: Learned three different ways to reverse a string—a classic interview favorite! Object Essentials: Introduction to Properties and Values. I practiced multiple ways to "get" and "set" data using dot notation and bracket notation. Advanced Object Ops: Working with nested objects, using Object.keys() and Object.values(), and learning how to safely delete properties. Iteration: Mastering how to loop through objects to pull out the data I need. Objects are truly the backbone of JavaScript, and I'm feeling much more confident in how to structure my code. 🚀 #JavaScript #WebDevelopment #CodingJourney #StringsAndObjects #FrontendDev #TechGrowth
To view or add a comment, sign in
-
-
Day 21: The Final Logic – Closures & The Magic of Property Access 🔒✨ Today marks the grand finale of the JavaScript deep-dive. We didn't just look at the code; we looked at the Memory and the Engine logic that governs how variables live and die. 🧠 The "Crack-It Kit" Checklist: Day 21 📑 🔹 The "Stack Overflow" Trap: Understanding why a setter that calls itself triggers a recursion loop, and the "Underscore Logic" (_variable) used to fix it. 🛡️ 🔹 Getters & Setters: Moving beyond simple data storage to "Smart Properties." Whether using Class syntax or Object.defineProperty, it's about intercepting and validating every piece of data. ⚙️ 🔹 The .length Mystery: Breaking down how arr.length actually works. It’s not just a counter—it’s an exotic property managed by the engine with a setter that can physically truncate memory. 🧪 🔹 Lexical Scoping: Mastering the "Hierarchy of Access." Understanding that where you write your code determines what your functions can see. 🏛️ 🔹 Closures (The Memory Lock): The ultimate interview topic. Learning how JS "locks" parent variables in memory to keep them alive for inner functions, even after the parent has finished executing. 🔒 The JavaScript foundation is now 100% complete. From the TCP 3-way handshake to the internal mechanics of Closures, the logic is locked in. 🏗️ #JavaScript #WebDevelopment #CrackItKit #Closures #WebEngineering #CodingJourney #SoftwareArchitecture #TechInterviews #MERNStack #WanderlustProject
To view or add a comment, sign in
-
-
Number of steps to reduce ........................ 47 🔥 ✅ Approach 🔹 Initialize: steps = 0 carry = 0 🔹 Traverse the binary string from right to left, ignoring the most significant bit (index 0). 🔹 For each bit: Compute bit + carry 👉 If the result equals 1 (number becomes odd): One step to add 1 One step to divide by 2 Total → 2 steps Set carry = 1 👉 Otherwise (number is even): Only divide by 2 Total → 1 step 🔹 After traversal, if a carry still remains, add it to the total steps. ✅ Return the final number of steps. This problem was a great exercise in understanding: ✔ Binary operations ✔ Carry propagation ✔ Efficient simulation without actual conversions 📌 Example Input: s = "1101" Binary "1101" corresponds to 13 in decimal. Step 1️⃣: 13 is odd → add 1 → 14 Step 2️⃣: 14 is even → divide by 2 → 7 Step 3️⃣: 7 is odd → add 1 → 8 Step 4️⃣: 8 is even → divide by 2 → 4 Step 5️⃣: 4 is even → divide by 2 → 2 Step 6️⃣: 2 is even → divide by 2 → 1 ✅ Output: 6 steps #JavaScript #TypeScript #SoftwareDevelopment #FrontendDeveloper #CodingJourney #DevelopersLife #LearningInPublic #ContinuousLearning #TechLearning #DeveloperGrowth #100DaysOfCode
To view or add a comment, sign in
-
-
Consistency > excuses. That’s today’s win. Day 10 | JavaScript – Objects Yesterday I missed posting. Today, I didn’t repeat that mistake. After getting comfortable with functions, I moved into objects — a cleaner and more powerful way to store related data. What I learned today: 1. Creating objects using { } 2. Storing data as key–value pairs 3. Accessing: -the whole object -individual properties using dot (.) notation 4. Updating values by reassigning properties 5. Removing properties completely using the delete keyword Objects made it clear how JavaScript organizes real-world data — not just values, but structure. Learning. Day 10 done. #JavaScript #Objects #LearningInPublic #WebDevelopment #DeveloperJourney
To view or add a comment, sign in
-
Javascript arrays are more powerful than you think. 🚀 I used to write complex for loops for data manipulation. Then I truly understood the power of array methods. It’s not just about shorter code—it’s about readability and intent. Three underused methods that deserve more love: .some(): Checks if at least one element passes a test. Great for validation. .every(): Checks if all elements pass. Perfect for form checking. .reduce(): The Swiss Army knife. From summing numbers to reshaping entire data structures. Clean code isn't about being clever; it's about making your logic obvious to the next developer who reads it (which is usually you, six months later). Which array method do you find yourself using the most? #JavaScript #Coding #SoftwareEngineering #WebDev #CleanCode
To view or add a comment, sign in
-
📌 #60 DailyLeetCodeDose Today's problem: 73. Set Matrix Zeroes – 🟡 Medium When a problem states that you must modify the data in-place, LeetCode has taught me a useful pattern: to boost performance and avoid extra memory, you can reuse the same mutable data structure to encode all the information you need. In this problem, instead of using additional arrays or hash sets, I use the first row and the first column of the matrix as markers – while scanning the matrix, whenever I encounter a zero, I mark its entire row and column by setting the corresponding cell in the first row or first column to zero. Since the first row and first column are also part of the original data, I store their initial state in two boolean flags. This allows me to correctly decide at the end whether they themselves should be zeroed out. As a result, the solution runs in O(m × n) time and uses O(1) extra space, fully satisfying the in-place requirement. https://lnkd.in/eRxwBy4g #DailyLeetCodeDose #LeetCode #JavaScript #Algorithms #ProblemSolving #Coding
To view or add a comment, sign in
-
-
🚀 Day 18 of Learning in Public: JavaScript Edition 💻✨ --Practice--Math operation, logs, data type Validation--Methods-- ✅ Arithmetic & Exponents (**) ✅ typeof Validation ✅ Template Literals (${}) ✅ Increment/Decrement (++, --) Code snippet 👇 ! #JavaScript #CodingJourney #LearningInPublic #TechCommunity #NodeJS #TestAutomation #JavaVsJS #SDET #ArrayMethods
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development