Understanding JavaScript Functions

🚀 Day 36/50 – Understanding Functions in JavaScript Today I explored one of the most important concepts in JavaScript — Functions. 🔹 A function is a reusable block of code designed to perform a specific task. 🔹 Functions help make code modular, reusable, and easy to maintain. 📌 1️⃣ Function Declaration function greet(name) { return "Hello, " + name + "!"; } console.log(greet("Priyanka")); 2️⃣ Function Expression const add = function(a, b) { return a + b; }; console.log(add(5, 3)); 3️⃣ Arrow Function (ES6) const multiply = (a, b) => { return a * b; }; console.log(multiply(4, 2)); ✔ Shorter syntax ✔ Cleaner and more readable 4️⃣ Default Parameters function welcome(name = "Guest") { return "Welcome, " + name; } console.log(welcome()); 💡 Key Learnings: ✅ Functions improve code reusability ✅ Arrow functions make code concise ✅ Parameters and return values make functions dynamic ✅ Clean function design is important for scalable applications #Day36 #50DaysOfCode #JavaScript #WebDevelopment #FrontendDevelopment #CodingJourney #LearningEveryday

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories