Tell us what’s happening:
This is concerning the problem:
“ES6: Use Destructuring Assignment with the Rest Parameter to Reassign Array Elements”
My code here works, and I’m not looking for a solution. But what I seek is understanding.
There is a declared const ‘source’ and the function removeFirstTwo(list)
List is the argument given. When we use this part of code
const [a, b, …arr] = list;
How does it know to use const source
as the array. what if there were more than one array in the code?
Thank you for the clarification.
Your code so far
const source = [1,2,3,4,5,6,7,8,9,10];
function removeFirstTwo(list) {
"use strict";
// Only change code below this line
const [a, b, ...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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36
.
Challenge: Use Destructuring Assignment with the Rest Parameter to Reassign Array Elements
Link to the challenge: