Javascript functions

Javascript functions

·

1 min read

hi hello welcome to my blog so now we are going to see what are functions?

Function is a piece of code is executed when you call that function.

so why we need Function?

a repeated piece of code which is written multiple times instead of that when we write that code inside a function we don't have to write repeated piece of code. simply we can call that function for repeated task with different arguments to produce different results.

definition of function?

Screenshot 2022-09-09 221346.png

Function with parameters

Screenshot 2022-09-09 222940.png

Function with Return

when we call a function it will perform some operation and return some result to the caller using return keyword

Screenshot 2022-09-09 223353.png

How to call Function?

we can call the function by function name( )

Screenshot 2022-09-09 224304.png

Passing values to the function and getting output

image.png