Function in JavaScript
A function let us store a block of of that we can use over & over again.
The general purpose of the function to make our life easier & make a effective program without repeating so many code.
Why we need that
Get Moniruzzaman Moni’s stories in your inbox
Join Medium for free to get updates from this writer.
Suppose,In your office you want to drink a cup of coffee.So,you give instruction to your assistance how to get coffee & what kind of coffee you want.So,whenever you call your assistance to get coffee you don’t have to describe all over again.In javascript,function works like same as command.You make once & called it whenever you need it .It will make your life a lot easier.
Function Declaration:
It consists of a function keyword,followed by:
- The name of the function.
- A list of parameters to the function,enclosed in parentheses ( , ) and separated by comma.
- Statement inside the {…} braces that defines the function.





