Tell us what’s happening:
I’m a bit confused about how this destructuring problem works. I understand the const [a,b
which assigns ‘a’ and ‘b’ to the 0 and 1 index. I also get that ...arr
takes the rest of the array and makes another array with the indexes. What I don’t understand is why it has to equal list
.
I kept thinking it would equal source
since that is the array I’m destructuring. I don’t get what the arg list
has to do with the problem.
Thank you in advance.
Your code so far
const source = [1,2,3,4,5,6,7,8,9,10];
function removeFirstTwo(list) {
"use strict";
// below
const [a,b,...arr] = list; // <—-help here
// above
return arr;
}
const arr = removeFirstTwo(source);
Your browser information:
User Agent is: Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 EdgiOS/45.3.19 Mobile/15E148 Safari/605.1.15
.
Challenge: Use Destructuring Assignment with the Rest Parameter to Reassign Array Elements
Link to the challenge: