Tell us what’s happening:
Hi all,
Could someone explain to me how this works? I’m sure I’m just having a lapse in concentration but I don’t understand how const [a, b, …arr] = list is receiving the array data from source.
This may just be me thinking how how things are done in different languages or vanilla JS but I would have assumed:
const [a, b, …arr] = source
Thanks in advanced
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);
console.log(arr);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0
.
Challenge: Use Destructuring Assignment with the Rest Parameter to Reassign Array Elements
Link to the challenge: