to remove first and last element in array

arrays, javascript

Solution

fruits.shift();  // Removes the first element from an array and returns only that element.
fruits.pop();    // Removes the last element from an array and returns only that element. 

See all methods for an Array.

Problem

How to remove first and last element in an array? For example: ``` var fruits = ["Banana", "Orange", "Apple", "Mango"]; ``` Expected output array: ``` ["Orange", "Apple"] ```

Original source

Related problems