๐๐ฎ๐๐ถ๐ฐ ๐๐๐ป๐ฐ๐๐ถ๐ผ๐ป๐ ๐ถ๐ป ๐๐ฎ v๐ฎ๐ฆ๐ฐ๐ฟ๐ถ๐ฝ๐ Functions in JavaScript help you organize code. They perform specific tasks. You can reuse them.
You can pass inputs to functions. They can perform actions and return outputs.
Here's how functions work:
- Parameters are placeholders in the function.
- Arguments are the actual values you pass when calling the function.
- Example: function greet(name) - 'name' is a parameter. greet("Alice") - "Alice" is the argument.
You can set default parameters. For example: function greet(name = "Guest").
Functions can return values. For example: function add(a, b) { return a + b; }.
You can pass values to functions using parameters. Parameters are listed inside the parentheses.
The return statement sends a value out of a function.
Source: https://www.w3schools.com/js/js_function_arguments.asp Optional learning community: https://dev.to/madhanraj/basic-functions-in-javascript-ejm