KoduFCC
October 21, 2024, 11:41pm
1
Tell us what’s happening:
I got it, but the removeFirstTwo([1, 2, 3, 4, 5]) should return [3, 4, 5], and I shouldn’t modify the original array. I need assistance on approaching this.
Your code so far
function removeFirstTwo(list) {
return list;
}
const [a, b, ...arr] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
const sourceWithoutFirstTwo = removeFirstTwo(a, b);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Challenge Information:
ES6 - Destructuring via rest elements
hbar1st
October 21, 2024, 11:47pm
2
so obviously you have to use destructuring assignment for this so have you tried to understand this example as a first step?
const [a, b, ...arr] = [1, 2, 3, 4, 5, 7];
console.log(a, b);
console.log(arr);
What do you think the 2nd log statement does?
KoduFCC
October 21, 2024, 11:52pm
3
It prints the arr, the rest of the array.
hbar1st
October 21, 2024, 11:54pm
4
so it prints out an array? And that array is minus the first 2 values?
(Hint Hint)
KoduFCC
October 21, 2024, 11:55pm
5
Yes, it prints the array minus the first 2 values. I’m not having trouble with that. I’m having trouble with getting the whole array minus the first two values, and minus the last values.
hbar1st
October 21, 2024, 11:56pm
6
I’m trying to be heavy-handed with the hints here.
The arr is the array minus the first 2 values.
And the objective of this exercise is ??? (double triple hint)
KoduFCC
October 22, 2024, 12:03am
7
Is to print the value of arr.
hbar1st
October 22, 2024, 12:04am
8
so are you still confused as to how to return an array with all the values except the first 2?
(hint: refer to that example again?)
system
Closed
April 22, 2025, 12:05pm
9
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.