Refactoring Shopping List Code with Modern JavaScript

Day 17 of #100DaysOfCode: Refactoring & The Art of "Unpacking" 📦 Today was a refactoring day. I took my Shopping List code from earlier this week and cleaned it up using modern JavaScript patterns. Two big changes I forced myself to make: Destructuring: Instead of writing item.name and item.price ten times, I learned to unpack them directly in the function arguments: const calculate = ({ price, qty }) => ... It cuts the noise and makes the code so much more readable. No forEach for logic: I set a strict rule: forEach is ONLY for printing to the console. Need a new array? Use map. Need a subset? Use filter. Need a total? Use reduce. DSA Update: Didn't get to DSA today. I got lost in the refactoring process, but getting the syntax right feels like a win. #JavaScript #WebDevelopment #CleanCode #100DaysOfCode #Refactoring

To view or add a comment, sign in

Explore content categories