Skip to content

Commit f520497

Browse files
Markus Amalthea Magnusonajpiano
Markus Amalthea Magnuson
authored andcommitted
Various small fixes on the JavaScript 101 Functions page. Fixes jquery#353.
1 parent bb79353 commit f520497

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

page/javascript-101/functions.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@ Functions can be created in a variety of ways, two of which are shown below:
1212

1313
```
1414
// Function declaration.
15+
1516
function foo() {
16-
/* do something */
17+
// Do something.
1718
}
1819
```
1920

2021
```
2122
// Named function expression.
23+
2224
var foo = function() {
23-
/* do something */
25+
// Do something.
2426
};
2527
```
2628

@@ -34,7 +36,7 @@ var greet = function( person, greeting ) {
3436
console.log( text );
3537
};
3638
37-
greet( "Rebecca", "Hello" );
39+
greet( "Rebecca", "Hello" ); // "Hello, Rebecca"
3840
```
3941

4042
```
@@ -45,7 +47,7 @@ var greet = function( person, greeting ) {
4547
return text;
4648
};
4749
48-
console.log( greet( "Rebecca", "hello" ) ); // "hello, Rebecca"
50+
console.log( greet( "Rebecca", "Hello" ) ); // "Hello, Rebecca"
4951
```
5052

5153
```
@@ -60,7 +62,7 @@ var greet = function( person, greeting ) {
6062
6163
var greeting = greet( "Rebecca", "Hello" );
6264
63-
greeting();
65+
greeting(); // "Hello, Rebecca"
6466
```
6567

6668
## Immediately-Invoked Function Expression (IIFE)
@@ -74,7 +76,7 @@ A common pattern in JavaScript is the immediately-invoked function expression. T
7476
var foo = "Hello world";
7577
})();
7678
77-
console.log( foo ); // undefined!
79+
console.log( foo ); // undefined!
7880
```
7981

8082
## Functions as Arguments
@@ -89,7 +91,7 @@ var myFn = function( fn ) {
8991
console.log( result );
9092
};
9193
92-
// logs "hello world"
94+
// Logs "hello world"
9395
myFn( function() {
9496
return "hello world";
9597
});

0 commit comments

Comments
 (0)