V
V
Vyacheslav Bagmut2018-02-19 13:05:38
JavaScript
Vyacheslav Bagmut, 2018-02-19 13:05:38

How to properly do Destructuring Assignment in ES6?

Hey! I can't complete the lesson on Freecodecamp - ES6: Use Destructuring Assignment with the Rest Operator to Reassign Array Elements ( https://beta.freecodecamp.org/en/challenges/es6/us...
Here is the code:

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

Only one test fails - "destructuring was used.". I ask for your help, the Freecodecamp forum and Google did not give an answer. what am I doing wrong?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question