ES6 - Destructuring via rest elements

Tell us what’s happening:
Destructuring on list should be used- is the error

Your code so far

const source = [1,2,3,4,5,6,7,8,9,10];
function removeFirstTwo(list) {
  "use strict";
  // change code below this line
  const [, , ...arr] = list;
  // change code above this line
  return arr;
}
const arr = removeFirstTwo(source);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36

Challenge: ES6 - Destructuring via rest elements

Link to the challenge:

This is the starting code:

function removeFirstTwo(list) {
  // Only change code below this line
  const shorterList = list; // Change this line
  // Only change code above this line
  return shorterList;
}

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

It looks like you made a bunch of changes outside of the comments telling you where to make changes… I’d remove all those extra changes. The changes look like you copied an old answer to the problem. I strongly recommend against doing that, as these challenges get updated and old answers often don’t work.

1 Like

Once you revert your code to the default, you will only need one line of code to solve this problem. Please refer to the example and hint. Good luck!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.