Tell us what’s happening:
Describe your issue in detail here.
I understand the answer as to why it is what it is but I don’t understand the code completely… Can someone explain to me in simple words the following questions i have?
- How are we able to pass in the list parameter but also define it within the function?
- What does the following line of code do in the context of this problem and is it also the reason why we are able to pass in the source into the removeFirstTwo function?
const sourceWithoutFirstTwo = removeFirstTwo(source); - If I have to summarize what confuses me its this. I know what the following code does
function removeFirstTwo(list) {
// Only change code below this line
const [a,b,…shorterList] = list; // Change this line
// Only change code above this line
return shorterList;
But I DO NOT UNDERSTAND WHAT THE CODE BELOW DOES
const source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
const sourceWithoutFirstTwo = removeFirstTwo(source);
}
Your code so far
function removeFirstTwo(list) {
// Only change code below this line
const [a,b,...shorterList] = list; // Change this line
// Only change code above this line
return shorterList;
}
const source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
const sourceWithoutFirstTwo = 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/111.0.0.0 Safari/537.36
Challenge: ES6 - Destructuring via rest elements
Link to the challenge: