Created
February 9, 2017 09:41
-
-
Save ecaepsey/07a63e8f4b3911b123f94df5f2749e07 to your computer and use it in GitHub Desktop.
just having fun with array
This file contains 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
function arrayManipulation(arr, command, location, value) { | |
if(command == "remove" && location =="end") { | |
return arr.pop(); | |
} else if (command =="remove" && location =="beginning") { | |
return arr.shift(); | |
} else if(command ="add" && location =="beginning") { | |
arr.unshift(value) | |
return arr | |
}else if(command ="add" && location=="end") { | |
arr.push(value); | |
return arr | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment