Back to articles
Functions in Javascript

Functions in Javascript

via Dev.toJanu Nirmal

Functions are sets of instructions. These are reusable building blocks which are used to execute a specific task whenever we need it. Uses of function: Syntax and explanation: 1) Function keyword — function What it means: This word tells the computer: 👉 "I am going to create a function." 2) Function name — sum What it means: This is the name of the function. You use this name later to run the function. 3) Parameters — (x, y) What it means: These are inputs the function expects to receive. Simple example: Like a calculator asking: 👉 "Give me two numbers." Here: x = first number y = second number 4) Function body — { } What it means: This is the working area of the function. All instructions are written inside these curly brackets. Simple example: Like a kitchen where cooking happens. 5) Return keyword — return What it means: This sends the result back after the work is done. Simple example: Like giving the answer after solving a problem. 👉 "Here is your result." 6) Statement — return x

Continue reading on Dev.to

Opens in a new tab

Read Full Article
3 views

Related Articles