Skip to content

Commit ecc6acf

Browse files
committedSep 28, 2018
feat(forEach): Add forEach snippet
1 parent 4c6c823 commit ecc6acf

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed
 

‎README.md

+42-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,43 @@
11
# code-snippets
2-
Example code with gifs
2+
3+
Code snippets with gifs, to avoid copy and paste the code and write it all.
4+
5+
## Files for each snippet
6+
7+
There is a file for each functionality, to be able to execute it.
8+
9+
Example:
10+
11+
- File es6/forEach/forEach.js
12+
13+
- Make it executable:
14+
15+
```
16+
chmod +x es6/forEach/forEach.js
17+
```
18+
19+
- Run it:
20+
21+
```
22+
./es6/forEach/forEach.js
23+
```
24+
25+
## Table of Contents
26+
27+
- [forEach](#forEach)
28+
29+
## forEach
30+
31+
> Example:
32+
33+
```javascript
34+
const array = ['this', 'is', 'a', 'test'];
35+
36+
array.forEach((item, index) => {
37+
38+
});
39+
```
40+
41+
> Gif:
42+
43+
![Escribir forEach paso a paso](es6/forEach/forEach.gif?raw=true)

‎es6/forEach/forEach.gif

944 KB
Loading

‎es6/forEach/forEach.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env node
2+
3+
const array = ['this', 'is', 'a', 'test'];
4+
5+
// ES6
6+
array.forEach((item1, index1) => {
7+
console.log({item1});
8+
console.log({index1});
9+
});
10+
11+
// ES5
12+
array.forEach(function(item2, index2) {
13+
console.log({item2});
14+
console.log({index2});
15+
});

0 commit comments

Comments
 (0)
Please sign in to comment.