๐๐ฎ๐๐ฎ๐ฆ๐ฐ๐ฟ๐ถ๐ฝ๐ ๐๐๐ป๐ฐ๐๐ถ๐ผ๐ป๐ ๐ญ๐ฌ๐ญ
Functions are reusable blocks of code. You use them to perform specific tasks. They act as sub-programs.
To create a function, follow these steps:
- Use the function keyword.
- Give the function a name.
- Add parameters in parentheses.
- Write your instructions in curly braces.
A function stays idle until you call it. To run it, use the name followed by parentheses.
Learn the difference between parameters and arguments:
- Parameters are placeholders.
- Arguments are the actual values you send.
Use the return keyword to get a result. It sends a value back to you and stops the function. Always place it at the end of your code.
Source: https://dev.to/kamalesh_ar_6252544786997/functions-in-javascript-with-keywords-lk6