20 lines
697 B
Markdown
20 lines
697 B
Markdown
|
---
|
||
|
title: Passing Values to Functions with Arguments
|
||
|
---
|
||
|
## Passing Values to Functions with Arguments
|
||
|
|
||
|
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
|
||
|
Our task is to create a function that has **parameters**. These are inputs that determine the function's output. You place paramaters inside the `()`, like so:
|
||
|
|
||
|
```javascript
|
||
|
function functionWithArgs(one, two) {
|
||
|
console.log(one + two);
|
||
|
}
|
||
|
```
|
||
|
We now have to add code inside the brackets. Our task is to add `one` and `two`, and print the sum to the console. Here is the basic code solution:
|
||
|
|
||
|
```javascript
|
||
|
functionWithArgs(7, 3);
|
||
|
//This will console log 10.
|
||
|
```
|