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

Just need the answer please, GitHub and YouTube didnt help

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

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) 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:

We don’t do that here. Its not allowed.

Your variable names don’t agree. arr is never used while shorterList is never declared.

Also, you should not reference the global variable source. You need to use the function argument.

1 Like

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