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.Disclaimer: the syntax below does not belong to any particular language, depending on the language it may be slightly different.
Example:
Making eggs:- Cracking an egg into a pan.
- Flip egg.
- Place on a plate.
Syntax:
Code:
function makeEggs() {
add egg to pan
flip egg
place egg on plate
}
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.