Skip to content

Instantly share code, notes, and snippets.

@sandrabosk
Last active January 21, 2020 03:10
Show Gist options
  • Save sandrabosk/68cba2c8be093dc31362cef86b434d44 to your computer and use it in GitHub Desktop.
Save sandrabosk/68cba2c8be093dc31362cef86b434d44 to your computer and use it in GitHub Desktop.

Use destructuring assignment with the rest operator to perform an effective Array.prototype.slice() so that arr is a sub-array of the original array source with the first two elements omitted.

const source = [1,2,3,4,5,6,7,8,9,10];

function removeFirstTwo(list) {
  // your code goes here
}

const arr = removeFirstTwo(source);
console.log(arr); // should be [3,4,5,6,7,8,9,10]
console.log(source); // should be [1,2,3,4,5,6,7,8,9,10];

Solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment