Function in JavaScript.
What is Functions in JavaScript? •Functions are reusable code blocks designed for particular tasks,You define it once, and then you can "call"(run) it whenever needed and it can be called multiple ...

Source: DEV Community
What is Functions in JavaScript? •Functions are reusable code blocks designed for particular tasks,You define it once, and then you can "call"(run) it whenever needed and it can be called multiple times as user want it. •Functions are executed when they are called. •Functions are fundamental in all programming languages. Function Parameters: •Parameters allow you to send values to a function. •Parameters are listed in parentheses() in the function definition. What Does a Function Look Like? •A function can be created with the function keyword, a name, and parentheses. •The code to run is written inside curly brackets. Example: function addNumbers(a, b) { let sum = a + b; return sum; } •The function above does not do anything. •It has to be called first. let result = addNumbers(5, 3); console.log(result); •Now the above code will run. What’s happening in this Code: 1. Function Declaration: ⇒function addNumbers(a, b) •You define a function named addNumbers. •It takes two parameters: a an