The final step involves mastering the use of `arguments` in functions. By learning how to use and manage these `arguments` effectively, you can unlock the full potential of your robot and make it later truly come alive.
console.log(arg1); // arg1 can be use inside the scope of the function
// ↖ arg1 is "transfered" to be the arg of console.log()
}; //<-endofthescopeofthefunction
```
Now if the function is called, it displays the output of `console.log(arg1)`.
```js
myFirstFunction("using my first arg"); // "using my first arg"
```
But let's say we want to change what the function logs. Now, instead of modifying `myFirstFunction` we just need to modify the `argument` in the `function call`.
```js
myFirstFunction("another arg"); // "another arg"
myFirstFunction("and another one"); // "and another one"
myFirstFunction("and one more"); // "and one more"
```
### More Arguments
We’ve seen how to add `one` argument to a function. Now, let’s learn how to add `two (or more)` arguments.
All we need to do to add a second argument `arg2` is to add a comma `,` after `arg1` and then add `arg2`.
// ↖ arg1 and arg2 are "transfered" to be the args of console.log()
};
// Now we call the function
myFirstFunction("first arg", "second arg");
// "first arg"
// "second arg"
```
For more args, you will need to simply repeat the same process! Comma `,` then the other argument and it goes on.
> Please note that you can name your arguments however you please. Just make sure that you reuse the proper name inside the scope of your function.
### Return value
In addition to accepting arguments, functions can also `return` values.
Return values are the `outputs` that a function provides after completing its task.
We are now going to adapt `myFirstFunction` so that it `returns` a value instead of just `logging it`.
```js
let myFirstFunction = (arg1) => {
return arg1; // the function now returns the value of arg1
};
```
Now if the function is called, it returns the value of `arg1`:
```js
let result = myFirstFunction("using my first return");
console.log(result); // "using my first return"
```
But let's say we want to change what the function `returns`. Now, instead of modifying `myFirstFunction`, we just need to modify `the argument` in `the function call`.
```js
let anotherResult = myFirstFunction("another return");
console.log(anotherResult); // "another return"
```
#### **`Prompt Example`**:
- "Can you guide me through creating and using a JavaScript function that takes multiple arguments, starting from a basic function without arguments, then adding single and multiple arguments ?"
As the leader of the RoboGuard forces, you're not just preparing for battle—you're also forming dynamic duos of robots to work together on special missions.
1- Create the `duos` Function:
- This function will take `two arguments`, representing the **names** of **two robots**.