Optimizing Logic & Cleaning Syntax with JavaScript

Day 10 of #100DaysOfCode: Optimizing Logic & Cleaning Syntax 🧹  Today was about efficiency. I didn't just write new code; I looked at how to make code run faster and look cleaner. DSA: The Square Root Trick I tackled Prime Number logic. The beginner way is to check every number from 2 to n-1. That’s O(n). But I learned you only actually need to check up to the square root of n. Result: The complexity drops to O(sqrt{n}). Lesson: Math saves computing power. Development: Modern JavaScript I revisited my BMI Calculator (from Day 2) and refactored the whole thing. I swapped out the old function declarations for Arrow Functions. Old: function calculate(weight, height) { ... } New: const calculate = (weight, height) => { ... } It’s a small syntax change, but it makes the code so much more readable and concise. Double digits! 10 days down. 🚀 #JavaScript #DataStructures #Optimization #WebDevelopment #CodingJourney

To view or add a comment, sign in

Explore content categories