You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: functions/declare.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,8 @@ function double(x) {
8
8
}
9
9
```
10
10
11
+
>*Note:* the function above **may** be referenced before it has been defined.
12
+
11
13
Functions are also values in JavaScript; they can be stored in variables (just like numbers, strings, etc ...) and given to other functions as arguments :
12
14
13
15
```javascript
@@ -16,6 +18,8 @@ var double = function(x) {
16
18
};
17
19
```
18
20
21
+
>*Note:* the function above **may not** be referenced before it is defined, just like any other variable.
22
+
19
23
---
20
24
21
25
Declare a function named `triple` that takes an argument and returns its triple.
Functions, like variables, must be declared. Let's declare a function `double` that accepts an **argument** called `x` and **returns** the double of x :
4
+
5
+
```javascript
6
+
function double(x) {
7
+
return 2 * x;
8
+
}
9
+
```
10
+
11
+
*Note*: the function above **may** be referenced before it has been defined.
12
+
13
+
Functions are also values in JavaScript; they can be stored in variables (just like numbers, strings, etc ...) and given to other functions as arguments :
14
+
15
+
```javascript
16
+
var double = function(x) {
17
+
return 2 * x;
18
+
};
19
+
```
20
+
21
+
*Note*: the function above **may not** be referenced before it is defined, just like any other variable.
22
+
23
+
---
24
+
25
+
Declare a function named `triple` that takes an argument and returns its triple.
0 commit comments