ES6 - Use Destructuring Assignment with the Rest Parameter to Reassign Array Elements

Tell us what’s happening:
Hello, I’m trying to pass this challenge and
though the code works, I’m getting the error of not applying destructuring assignment on the list parameter.
I checked up the solution, but no dice.
Your code so far

function removeFirstTwo(list) {
  // Only change code below this line
  const  [a,b, ...arr] = list;
  const shorterList = [...arr];   // 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);
console.log(removeFirstTwo(source));

Your browser information:

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

Challenge: ES6 - Use Destructuring Assignment with the Rest Parameter to Reassign Array Elements

Link to the challenge:

I strongly recommend against looking up the solutions in the guide until you have written your own answer.

This line isn’t helping you at all.

This line is backwards from the syntax in the example. The three dots go on the left side of the = instead of the right.

You need only change the specified line. You don’t need to add anything else.
It’s basically pretty similar to the example given in the exercise.

Hey thanks just passed it…

const [ ,, ...shorterList ] = list;

1 Like