🚀 Day 7 of My 30 Days of JavaScript Journey ✅ Challenge: Array Reduce Transformation (LeetCode #2626) Write a function reduce(nums, fn, init) that processes each element of the array using the given reducer function fn, starting from an initial value init. This function should accumulate results sequentially and return the final value — implemented without using the built-in Array.reduce() method. 💻 Language Used: JavaScript ❓ Problem Link: https://lnkd.in/gxsp26cz 💡 Solution: https://lnkd.in/giZj_hYw 🧠 Concept Highlighted: This problem deepened my understanding of accumulator functions, data aggregation, and sequential computation in JavaScript. It helped me explore how the powerful reduce() method works behind the scenes — a key tool for transforming and summarizing data efficiently. #Day7 #JavaScript #LeetCode #30DaysOfCode #CodingChallenge #WebDevelopment #FrontendDevelopment #LearningEveryday #ProblemSolving #FunctionalProgramming
Implementing Array Reduce in JavaScript for LeetCode Challenge
More Relevant Posts
-
🚀 Day 5 of My 30 Days of JavaScript Challenge 🧩 Problem: Apply Transform Over Each Element in Array (LeetCode #2635) Given an integer array arr and a mapping function fn, return a new array such that: newArray[i] = fn(arr[i], i) Solve this without using the built-in Array.map() method. 💻 Language: JavaScript ❓ Question: https://lnkd.in/eq8qYfpb 💡 Solution: https://lnkd.in/eT5U2kBp 🧠 Concepts Used: Higher-order functions (passing functions as arguments) Loops and callback functions Core idea behind how .map() works internally 📚 Takeaway: By recreating the Array.map() method manually, I learned how callback execution and array transformations work under the hood — a must-know for mastering JavaScript fundamentals. #Day5 #JavaScript #30DaysOfCode #LeetCode #CodingChallenge #WebDevelopment #FrontendDevelopment #100DaysOfCode
To view or add a comment, sign in
-
🚀 Day 6 of My 30 Days of JavaScript Challenge 🧩 Problem: Filter Elements from Array (LeetCode #2634) Given an integer array arr and a filtering function fn, return a new array filteredArr that only includes elements where fn(arr[i], i) returns a truthy value. Solve this without using the built-in Array.filter() method. 💻 Language: JavaScript ❓ Question: https://lnkd.in/eSGpgXcM 💡 Solution: https://lnkd.in/ekA6y-u3 🧠 Concepts Used: Higher-order functions and callbacks Conditional checks for truthy/falsy values Understanding Boolean(value) behavior in JavaScript 📚 Takeaway: Rebuilding filter() from scratch deepens understanding of conditional logic, iteration, and truthy/falsy evaluation — all essential for functional programming in JavaScript. #Day6 #JavaScript #30DaysOfCode #LeetCode #CodingChallenge #WebDevelopment #FrontendDevelopment #100DaysOfCode
To view or add a comment, sign in
-
🚀 Day 44 of #100DaysOfWebDevelopment Challenge Today, I continued exploring JavaScript Arrays and learned some advanced yet essential concepts that deepen the understanding of how arrays behave and interact in memory. 🔹 sort() Method I learned how the sort() method arranges elements in an array. By default, it sorts elements as strings (lexicographically), which can sometimes lead to unexpected results with numbers. To handle numeric sorting, we can pass a compare function to customize the sorting logic. 🔹 Array References Arrays in JavaScript are reference types, meaning when we assign one array to another variable, both variables point to the same memory location. So, changing one array affects the other — an important behavior to remember when manipulating data. 🔹 Constant Arrays Even if an array is declared using const, its elements can still be modified. The const keyword only prevents reassigning the variable reference — not changing the contents of the array itself. 🔹 Nested Arrays I also explored nested arrays, which are arrays within arrays. They’re useful for representing structured or tabular data, and elements can be accessed using multiple indices (e.g., arr[1][2]). 💡 Key Takeaway: Today’s topics gave me a deeper understanding of how arrays work behind the scenes — especially regarding memory references, sorting, and managing complex data structures like nested arrays. #100DaysOfCode #WebDevelopment #JavaScript #FrontendDevelopment #CodingJourney #LearningInPublic
To view or add a comment, sign in
-
-
🚀 Day 4 of My 30 Days of JavaScript Challenge 🧩 Problem: Create Counter II (LeetCode #2665) Write a function createCounter(init) that returns an object with three functions: increment() → increases the current value by 1 and returns it decrement() → decreases the current value by 1 and returns it reset() → resets the value back to init and returns it 💻 Language: JavaScript ❓ Question: https://lnkd.in/eupkr-a3 💡 Solution: https://lnkd.in/eq3BEsn2 🧠 Concepts Used: Closures for maintaining private state across function calls Object methods to encapsulate multiple related actions State management inside functions 📚 Takeaway: This challenge reinforces closures and encapsulation — two powerful ideas that make JavaScript functions behave like real objects with memory and behavior. #Day4 #JavaScript #30DaysOfCode #LeetCode #CodingChallenge #WebDevelopment #FrontendDevelopment #100DaysOfCode
To view or add a comment, sign in
-
🚀 STOP GUESSING! 🛑 Ever wondered why changing one JavaScript variable sometimes changes another? You've stumbled into the most crucial concept for any JS developer: Stack vs. Heap Memory! 🤯 I just dropped a new video that tackles Chapter 2 of our DSA series: How JavaScript Handles Data. In this deep dive, you'll master: ✨ Primitive vs. Reference Data Types (The ultimate differentiator!) 🧠 The Stack (Why simple values are fast!) 📦 The Heap (Where your objects and arrays actually live!) 🔑 The critical concept of Copy by Value vs. Copy by Reference that breaks code. If you're preparing for interviews 💼 or just want to write less buggy code, this is mandatory viewing. Stop letting the memory model be a mystery! 📺 Watch the full video here: [Link in comment] Join TechCraft Club: https://lnkd.in/gHU3iqnX Let me know in the comments: What's the one memory concept that confused you the most when you started coding? 👇 #JavaScript #DSA #Coding #TechCareers #SoftwareDevelopment #StackVsHeap #ProgrammingTips #WebDevelopment
To view or add a comment, sign in
-
-
🫢 Ever wondered what happens behind the scenes when you reassign a value in JavaScript? 🤔 👉 When you update a primitive data type (like string, number, boolean, undefined, null, symbol, or bigint), you’re not actually changing the existing value. 👉 Instead, JavaScript silently creates a new value in memory and points your variable to it. 🎯 👉 It’s like getting a brand-new notebook instead of erasing the old one — the old still exists, but you’ve just started fresh. 📒 ✨ So, while it looks like you’re modifying the value, you’re actually reassigning a new memory reference every time. 🌠 As they say, “Appearances can be deceiving.” 😉 The value seems to change, but deep down, it never truly does! 💡 In short: We often know that strings are immutable, but here’s the twist — all primitive data types are immutable in JavaScript! 🔥 💬 Idiom: “Appearances can be deceiving.” — Things may not be as they seem; something that looks one way on the surface may actually be very different underneath. #JavaScript #CodingTips #Programming #TechInsights #LearnToCode #DeveloperLife #FrontendDevelopment #CodeWisdom #ProfessionalLearning #CareerGrowth #JS #WebDevelopment
To view or add a comment, sign in
-
-
🚀 Day 3 of My 30 Days of JavaScript Challenge 🧩 Problem: Implement expect() Function (LeetCode #2704) Write a function expect that helps developers test their code. It takes a value val and returns an object with two methods: toBe(val) → returns true if both values are strictly equal (===), else throws "Not Equal" notToBe(val) → returns true if both values are not strictly equal (!==), else throws "Equal" 💻 Language: JavaScript ❓ Question: https://lnkd.in/eJcRKeme 💡 Solution: https://lnkd.in/eZY9mYHN 🧠 Concepts Used: Higher-order functions (function returning object with functions) Error handling using throw new Error() Strict equality (===) in JavaScript 📚 Takeaway: This exercise reinforces function design, object methods, and error handling — the foundation for building custom testing utilities and debugging tools in JavaScript. #Day3 #JavaScript #LeetCode #30DaysOfCode #CodingChallenge #WebDevelopment #FrontendDevelopment #100DaysOfCode
To view or add a comment, sign in
-
Building a Basic Calculator in JavaScript 🔹 Ever wondered how to evaluate a math expression like '1 + (4 + 5 + 2) - 3' in JavaScript without using eval()? Here's a clean way to do it using stacks. Key Concepts: Stack for previous results and signs: Keeps track of nested parentheses. Sign management: Helps handle + and - correctly. Iterative parsing: Converts string digits into numbers. Avoids the dangers of eval(). Can handle nested parentheses. Shows how stack-based algorithms can solve real-world problems elegantly.
To view or add a comment, sign in
-
-
🚀 Day 4 of My 30 Days of JavaScript Journey ✅ Challenge: Create Counter Object (LeetCode #2665) Write a function createCounter(init) that returns an object with three functions: increment() → increases the value by 1 and returns it. decrement() → decreases the value by 1 and returns it. reset() → resets the value to the initial value and returns it. 💻 Language Used: JavaScript ❓ Problem Link: https://lnkd.in/gKxPxb8Y 💡 Solution: https://lnkd.in/g3jv6Nfi 🧠 Concept Highlighted: This challenge strengthens understanding of closures and object methods in JavaScript. It shows how functions can preserve and modify internal state — a key concept in building dynamic, stateful applications. #JavaScript #LeetCode #30DaysOfCode #CodingChallenge #WebDevelopment #FrontendDevelopment #LearningEveryday #Closures #ProblemSolving
To view or add a comment, sign in
-
Today I learned three powerful JavaScript methods: map(), filter(), and reduce() 🧠 These methods make working with arrays super efficient — instead of writing long loops, you can do everything in just a few lines of clean code! map() → transforms each element filter() → filters elements based on condition reduce() → reduces all elements into a single value (like sum or total) Learning how they work together really changed the way I think about data manipulation in JS 😍 #JavaScript #FrontendDevelopment #CodingJourney #WebDevelopment #LearningEveryday
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