JavaScript Simplified: Array Iteration Methods

🚀 JavaScript Simplified Series — Day 13 Arrays are powerful… But what if you want to process every element automatically? 🤔 Imagine this 👇 You have a list of prices: [100, 200, 300] Now you want to: 👉 Double every price 👉 Filter expensive items 👉 Get total price Will you use loops every time? ❌ JavaScript gives a smarter way… 👉 Array Iteration Methods 🔹 1. map() → Transform every element let prices = [100, 200, 300] let updated = prices.map(price => price * 2) console.log(updated) 👉 Output: [200, 400, 600] 📌 map() returns a new array 🔹 2. filter() → Select specific elements let prices = [100, 200, 300] let expensive = prices.filter(price => price > 150) console.log(expensive) 👉 Output: [200, 300] 📌 filter() returns elements that match condition 🔹 3. reduce() → Combine all values let prices = [100, 200, 300] let total = prices.reduce((acc, price) => acc + price, 0) console.log(total) 👉 Output: 600 📌 reduce() gives a single value 🔥 Real Life Example Shopping cart 🛒 map() → apply discount filter() → find expensive items reduce() → calculate total bill 🔥 Simple Summary map → transform data filter → select data reduce → combine data 💡 Programming Rule Don’t write loops again and again. Use smart methods. If you want to learn JavaScript in a simple and practical way, you can follow these YouTube channels: • Rohit NegiHitesh Choudhary (Chai aur Code) 📌 Series Progress Day 1 → What is JavaScript Day 2 → Variables & Data Types Day 3 → Type Conversion & Operators Day 4 → Truthy & Falsy + Comparison Operators Day 5 → If Else + Switch + Ternary Day 6 → Loops Day 7 → Break + Continue + Nested Loops Day 8 → Functions Basics Day 9 → Arrow + Default + Rest Parameters Day 10 → Callback & Higher Order Functions Day 11 → Arrays Basics Day 12 → Array Methods (Basic) Day 13 → Array Iteration (map, filter, reduce) Day 14 → Advanced Array Methods (Next Post) Follow for more 🚀 #JavaScriptSimplified #javascript #webdevelopment #coding #programming #learninpublic #100DaysOfCode #frontenddevelopment #devcommunity #codingjourney #softwaredeveloper #techcommunity #dailylearning #codeeveryday

To view or add a comment, sign in

Explore content categories