Skip to content

Instantly share code, notes, and snippets.

@jvandy83
Created March 6, 2019 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jvandy83/5aeb6545fc4e0c5c0da9bf84b02a4502 to your computer and use it in GitHub Desktop.
Save jvandy83/5aeb6545fc4e0c5c0da9bf84b02a4502 to your computer and use it in GitHub Desktop.
I'm perplexed...can someone clear this up for me???
// Write a function called "removeFromBackOfNew".
// Given an array, "removeFromBackOfNew" returns a new array containing all but the last element of the given array.
var arr = [1, 2, 3];
function removeFromBackOfNew(arr) {
var newArr = arr.slice([0], [2]);
return newArr;
}
// When I run test it says the 'last element in the passed array must be removed.'
// var output = removeFromBackOfNew(arr); <--- This is
// console.log(output); // --> [1, 2] <------- the desired
// console.log(arr); // --> [1, 2, 3] <------- result.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment