Skip to content

Instantly share code, notes, and snippets.

@schamblee
Created January 19, 2018 20:48
Show Gist options
  • Save schamblee/531fae570f1883ba17e619283257c9e8 to your computer and use it in GitHub Desktop.
Save schamblee/531fae570f1883ba17e619283257c9e8 to your computer and use it in GitHub Desktop.
Creating arrays
function makeList(item1, item2, item3) {
return [item1, item2, item3]
}
Adding array items
function addToList(list, item) {
list.push(item);
return list;
}
Accessing array items
function accessFirstItem(array) {
return array[0];
}
function accessThirdItem(array) {
return array[2];
}
Array length and access
function findLength(array) {
return array.length;
}
function accessLastItem(array) {
return array[array.length-1]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment