Skip to content

Instantly share code, notes, and snippets.

@ecaepsey
Created February 9, 2017 09:41
Show Gist options
  • Save ecaepsey/07a63e8f4b3911b123f94df5f2749e07 to your computer and use it in GitHub Desktop.
Save ecaepsey/07a63e8f4b3911b123f94df5f2749e07 to your computer and use it in GitHub Desktop.
just having fun with array
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