Posts

Showing posts from November, 2025
Image
  Understanding JavaScript Functions    Introduction JavaScript is the heart of front-end logic . Two of its most important concepts are Functions and Arrays . Understanding these makes you a confident developer who can write clean, reusable, and efficient code. “Functions organize your logic. Arrays organize your data.” JavaScript Functions   What is a Function? A function is a block of code designed to perform a specific task. It runs when it is called or invoked . Function Syntax: function functionName(parameter1, parameter2) {   // code to be executed   return result; } Example 1 — Simple Function f unction greet() {   console.log("Welcome to JavaScript!"); } greet(); // Output: Welcome to JavaScript! Explanation: function greet() → defines the function greet(); → calls the function Example 2 — Function with Parameters function calculateSalary(basic, bonus) {   return basic + bonus; } console.log(calculateSalary(30000, 5000)); ...