Tell us what’s happening:
What is sub-array? I am lost in the question of where it is telling
you cannot use the rest parameter to catch a subarray that leaves out the last element of the original array.
and question part
so that arr is a sub-array of the original array source with the first two elements omitted.
As I am not too sure about what is being asked I did the following
const source = [1,2,3,4,5,6,7,8,9,10];
function removeFirstTwo(list) {
// Only change code below this line
const arr = [,,...list]; // Change this line
// Only change code above this line
return arr;
}
const arr = 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/105.0.0.0 Safari/537.36
Challenge: ES6 - Use Destructuring Assignment with the Rest Parameter to Reassign Array Elements
It is asking for rest, not spread. So what you have needs to be on the left-hand side (with arr not list)
Not sure why the text is talking about rest parameter though. As clearly by the name that would involve parameters. MDN calls it a rest property when …rest is used with a destructuring assignment.
[a,b,c,d,e,f] is an array b,c,d or a,b,c or d.e.f are sub-array ( any partial of the array is sub-array)
the key of this challenge I think should be rest parameter
try visit this link to get idea of rest parameter Rest parameters - JavaScript | MDN
When you use rest parameter You take all the rest as an array
for example
var [a,b , …c] = [1,2,3,4,5]
a = 1
b = 2
c = [3,4,5] you can not take only [3,4] and left 5