๐๐ฎ๐๐ฎ๐ฆ๐ฐ๐ฟ๐ถ๐ฝ๐ ๐๐๐ป๐ฐ๐๐ถ๐ผ๐ป๐
Functions are code blocks. They do one task.
Why use functions?
- Reuse your code.
- Organize your work.
- Read your code faster.
How to build one:
- Use the function keyword.
- Give it a name.
- Put your code in curly brackets.
Functions run when you call them. Use the same function many times.
Variables inside a function are local. Only the function sees them. You use the same variable name in different functions.
Store function results in variables.
How data moves:
- Parameters: Send values to the function.
- Arguments: The function receives values.
- Code: The function does work.
- Return: The function gives a value back.
Source: w3schools.com Optional learning community: https://dev.to/vidhya_murali_5aabe7784bd/functions-in-javascipt-19ei