Freecodecamp: [beta] Arr is not changed to [1, 2, 3, 4, 5, 6], but to [1, 2, 3, [4, 5, 6]]

Created on 26 Jun 2017  路  6Comments  路  Source: freeCodeCamp/freeCodeCamp

Challenge add-elements-to-the-end-of-an-array-using-concat-instead-of-push has an issue.
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36.

In following example:


var arr = [1, 2, 3];
arr.push([4, 5, 6]);
// arr is changed to [1, 2, 3, 4, 5, 6]
// Not the functional programming way

arr is not changed to [1, 2, 3, 4, 5, 6], but to [1, 2, 3, [4, 5, 6]]

help wanted

All 6 comments

Nothing is wrong with this challenge. The challenge is asking you to use the actual word CONCAT and remember to start your code before the return statement. I did this challenge and it worked. The key is in the wording right above Run Test. I will help you out with a little snippet you can figure out the rest
var res = first.concat(second); . You have to change a _word_ in the return statement.

@Snip3rSVK please reread the instructions, "The last challenge introduced the concat method as a way to combine arrays into a new one without mutating the original arrays."
Also if you need a refresher on the concat method view the previous challenge.

For more help try sharing your code and ask for hints, tips, and code review in the Freecodecamp Chatrooms specifically @Snip3rSVK you want to join HelpJavascript
Happy Coding! :tada: :smile: :tada:

@4mifix, @tommygebru sorry maybe I expressed wrong. I know how to complete the challenge and I know that challenge is working properly. I meant, that note in example of how push method adds item to end of array is wrong. Specifically this note: // arr is changed to [1, 2, 3, 4, 5, 6] - well arr is not changed to [1, 2, 3, 4, 5, 6], but to [1, 2, 3, [4, 5, 6]]. It's a little detail but still :)

Oh I see in the example :+1: I will see if we can change this :smile: @Snip3rSVK

@Snip3rSVK thanks for the issue. Yes, I agree that the example should be changed to be more accurate :+1:

For people interesting in taking this issue, please first read the contributing guidelines before taking care of this issue. And feel free to visit the Contributors Help chat room if you have any questions about helping. We're there to help.

@erictleung just got home I provided the change here https://github.com/freeCodeCamp/freeCodeCamp/pull/15545

Was this page helpful?
0 / 5 - 0 ratings