diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-operator-to-reassign-array-elements.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-operator-to-reassign-array-elements.english.md index 437aafef83..65b56a48b0 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-operator-to-reassign-array-elements.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-with-the-rest-operator-to-reassign-array-elements.english.md @@ -25,10 +25,10 @@ Use destructuring assignment with the rest operator to perform an effective arr should be [3,4,5,6,7,8,9,10] testString: assert(arr.every((v, i) => v === i + 3) && arr.length === 8,'arr should be [3,4,5,6,7,8,9,10]'); - - text: Destructuring should be used. - testString: getUserInput => assert(getUserInput('index').match(/\[\s*\w*\s*,\s*\w*\s*,\s*...\w+\s*\]/g),'Destructuring should be used.'); - text: Array.slice() should not be used. testString: getUserInput => assert(!getUserInput('index').match(/slice/g), 'Array.slice() should not be used.'); + - text: Destructuring on list should be used. + testString: getUserInput => assert(getUserInput('index').match(/\s*\[\s*,\s*,\s*\.\.\.\s*arr\s*\]\s*=\s*list\s*/g), 'Destructuring on list should be used.'); ``` @@ -44,7 +44,7 @@ const source = [1,2,3,4,5,6,7,8,9,10]; function removeFirstTwo(list) { "use strict"; // change code below this line - arr = list; // change this + const arr = list; // change this // change code above this line return arr; } @@ -63,6 +63,14 @@ console.log(source); // should be [1,2,3,4,5,6,7,8,9,10];
```js -// solution required +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); ```