Created
July 11, 2019 20:18
-
-
Save mallorywhitman/8b1061be3f8de0e99a233313cd4355db to your computer and use it in GitHub Desktop.
Lab Solved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var chocolateBars = ["snickers", "hundred grand", "kitkat", "skittles"] | |
function addElementToBeginningOfArray(array,element){ | |
return [element, ...array]; | |
} | |
function destructivelyAddElementToBeginningOfArray(array,element){ | |
var alteredArray = array.unshift(element); | |
return array; | |
} | |
function addElementToEndOfArray(array,element){ | |
var newArray = [...array,element]; | |
return newArray; | |
} | |
function destructivelyAddElementToEndOfArray(array,element){ | |
var destroyedArray= array.push(element); | |
return array; | |
} | |
function accessElementInArray(array,index){ | |
return array[index]; | |
} | |
function destructivelyRemoveElementFromBeginningOfArray(array){ | |
var shiftedArray = array.shift(); | |
return array; | |
} | |
function removeElementFromBeginningOfArray(array){ | |
var slicedArray = array.slice(1); | |
return slicedArray; | |
} | |
function destructivelyRemoveElementFromEndOfArray(array){ | |
var popedArray = array.pop(); | |
return array; | |
} | |
function removeElementFromEndOfArray(array){ | |
var lastElementSliced = array.slice(0, array.length-1); | |
return lastElementSliced; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ♥ learn | |
> [email protected] test /home/balanced-forum-1693/javascript-arrays-bootcamp-prep-001 | |
> mocha -R mocha-multi --reporter-options nyan=-,json=.results.json | |
18 -_,------, | |
0 -_| /\_/\ | |
0 -^|__( ^ .^) | |
- "" "" | |
18 passing (610ms) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment