Skip to content

Commit

Permalink
Add live example for Array iterator (mdn#1570)
Browse files Browse the repository at this point in the history
* Fix order on meta.json

* Fix Identation and add suffix to variables
  • Loading branch information
bsunderhus authored Apr 24, 2020
1 parent b8fc0b0 commit 8695185
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions live-examples/js-examples/array/array-iterator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const array1 = ['a', 'b', 'c'];
const iterator1 = array1[Symbol.iterator]();

for (const value of iterator1) {
console.log(value);
}

// expected output: "a"
// expected output: "b"
// expected output: "c"
6 changes: 6 additions & 0 deletions live-examples/js-examples/array/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@
"title": "JavaScript Demo: Array.indexOf()",
"type": "js"
},
"arrayIterator": {
"exampleCode": "./live-examples/js-examples/array/array-iterator.js",
"fileName": "array-iterator.html",
"title": "JavaScript Demo: Array.prototype[@@iterator]()",
"type": "js"
},
"arrayJoin": {
"exampleCode": "./live-examples/js-examples/array/array-join.js",
"fileName": "array-join.html",
Expand Down

0 comments on commit 8695185

Please sign in to comment.