Assignment with the Rest Operator to Reassign Array Elements

Assignment with the Rest Operator to Reassign Array Elements


I am a newbie. I got the right answer from the Hint section, I’m just not sure why this line was accepted as correct.


You should be using the array which was passed into the removeFirstTwo function instead of hard-coding the [1, 2] array. Do you understand what variable you should be using as the array on the right side of assignment above?


At a guess, it was a bug. There is ABSOLUTELY NO reason why it should pass. If you echo a, b, arr within the function, you’ll see that arr is an empty array. So I lean towards you found a bug.


yes the answer is: const [,…arr] = list;


it is, yes. And when I ran your code it DOES pass. but oddly, if you watch teh console.log, you can see that arr is, in fact, [].


yes, I notice that when I copied and pasted the code in []

Will they fix the bug?


One of the tests is checking the following assertion:

assert(arr.every((v, i) => v === i + 3));  // returns true because it is an empty array.


Well, THAT’S interesting. Would another likely assertion be to check that the returned length is two less than the original length? If that is the purpose of the function? In that way, even if the current assertion passes, the new one wouldn’t.


There are many other tests which would catch this problem. Maybe one of you would create an issue on Github for this? Just do a search first to make the same issue has not already been reported.


Gentleman, I am a toddler trying to understand javascript, by doing two hours a day on your site. I hope to be half as good as you, in a couple of years.


lol @freedm55 – years and years at this, I’m still a noob. It’s all practice, and helping others. I’ve searched through the github, there is one other error reported for this particular task, but it’s a typo rather than an assertion issue. I’ll set up the issue, if you like. Unless you want to claim it, @freedm55, as you are the discoverer of this one.


Please set up the issue and claim it. I am a 52 year old beginner just hoping to someday be competent at this. Thank you for reaching out and helping.


Done and done: See your issue!

And I’ve been at this since 1986, in one form or another, and I’m still a work in progress. I’ll be 49 years young this year, and I’m excited about all the fun advances i see coming!! :wink:


Unless they can figure out how to extend human life for another 30 years, I am delusional to think I can become a web developer and change careers before I die. :exploding_head:


absolutely not. What you think may take thirty years can be done in three, if you have curiosity and a willingness to let go of ideas that may hold you back. The first of which is, “I can’t learn everything before I go!”

If you want to pursue the possibility of web development as a career change, freecodecamp is a great place to start. Also, get to some local meetups. Network, get to local events, see how others are thinking and what they’re doing. Challenge your thoughts every day. Tomorrow, you’re going to be a more mature coder than you are today.


Thanks, I appreciate the advice. On a good day, I can spend 3 hours of study before getting mental fatigue. I guess compounded 7 days a week for 3 years should yield some aha moments and eventually hire-able skills. :slight_smile:


Hell, a good WEEK can yield marketable skills. Have you SEEN the jobs being given to kids fresh outta high school? Bud, you and I got them beat with sheer life experience!


Yes I agree, but I’ll be honest, everything I ever set my mind to, I got good at, once I set my mind to it. However, this new challenge, of learning how to code (which is a ‘super power’ as far as I’m concerned) is very difficult to learn for me. I don’t know why but its freaking hard. I will not give up.


@snowmonkey Fantastic!!! I saw the other older issue which was unrelated. Now, let me see if I can create the applicable tests for this issue and I will request a PR to get it implemented into the curriculum.


Thank you, @RandellDawson, I appreciate all your hard work, both in the forums and on the curriculum. It’s been a huge asset, and one I’ve been excited about directing folks to lately, when they ask how to get started. :wink: