Use-destructuring-assignment-with-the-rest-operator-to-reassign-array-elements // Szabi

Use-destructuring-assignment-with-the-rest-operator-to-reassign-array-elements // Szabi
0.0 0

#1

Tell us what’s happening:
Hello,

I have a problem with this lesson, I don’t know what I’m doing wrong, the output is good but I’m missing something.
Can you advise on this?

Cheers,
Szabi

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 this
  // change code below this line
  return arr;
}
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];

Your browser information:

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

Link to the challenge:


#2

I tried this which also fails the tests:

const source = [1,2,3,4,5,6,7,8,9,10];
function removeFirstTwo(list) {
  "use strict";
  // change code below this line
  const [x,y,...newlist] = list;
  console.log(newlist);
  // change this
  // change code below this line
  return newlist;
}
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];

Clearly I am using destructuring.


#3

Looks like there is a know issue