Skip to content

Commit

Permalink
feat: showcase basic array functionality (#2253)
Browse files Browse the repository at this point in the history
* feat: showcase basic array functionality

* feat: demo 0-index and `[]` retrieval on arrays

* feat: show that arrays can contain different types

* docs: document `.length` property on arrays

* fix: `eslint` errors

* style: make code compact by deleting empty lines

* refactor: remove third example

---------

Co-authored-by: Queen Vinyl Da.i'gyu-Kazotetsu <vinyldarkscratch@gmail.com>
  • Loading branch information
hamirmahal and queengooborg committed Aug 2, 2023
1 parent 4b86d33 commit 2136a11
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions live-examples/js-examples/array/array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const names = [];
names.push('Aisha');
names.push('Bem');
console.log(names); // [ 'Aisha', 'Bem' ]
console.log(names[-1]); // undefined
console.log(names[0]); // "Aisha"
console.log(names[1]); // "Bem"
console.log(names.length); // 2

const top = names.pop();
console.log(top); // 'Bem'
console.log(names); // [ 'Aisha' ]
console.log(names.length); // 1
6 changes: 6 additions & 0 deletions live-examples/js-examples/array/meta.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"pages": {
"array": {
"exampleCode": "./live-examples/js-examples/array/array.js",
"fileName": "array.html",
"title": "JavaScript Demo: Array",
"type": "js"
},
"arrayAt": {
"exampleCode": "./live-examples/js-examples/array/array-at.js",
"fileName": "array-at.html",
Expand Down

0 comments on commit 2136a11

Please sign in to comment.