What is a function?
A function... what is a function? A function is a group or set of instructions that can be called anytime. A function is a great way to reuse code without actually writing it over and over again.Example:
Making eggs:- Cracking an egg into a pan.
- Flip egg.
- Place on a plate.
Syntax:
[CODE title="function syntax"]function makeEggs() {add egg to pan
flip egg
place egg on plate
}[/CODE]
With this function, we can call by using
makeEggs();
within our code and it will execute the code within the makeEggs function. Once code has been successfully been executed it will return after where the function was called.