Code change:
Functional programming is all about creating and using non-mutating functions. <del> The last challenge introduced the `concat` method as a way to combine arrays into a new one without mutating the original arrays. Compare `concat` to the `push` method. `push` adds an item to the end of the same array it is called on, which mutates that array. Here's an example: </del> <ins> The last challenge introduced the `concat` method as a way to merge arrays into a new array without mutating the original arrays. Compare `concat` to the `push` method. `push` adds items to the end of the same array it is called on, which mutates that array. Here's an example: </ins> ```js const arr = [1, 2, 3]; <del> arr.push([4, 5, 6]); </del> <ins> arr.push(4, 5, 6); </ins> ``` <del> `arr` would have a modified value of `[1, 2, 3, [4, 5, 6]]`, which is not the functional programming way. </del> <ins> `arr` would have a modified value of `[1, 2, 3, 4, 5, 6]`, which is not the functional programming way. </ins> <del> `concat` offers a way to add new items to the end of an array without any mutating side effects. </del> <ins> `concat` offers a way to merge new items to the end of an array without any mutating side effects. </ins> # --instructions-- <del> Change the `nonMutatingPush` function so it uses `concat` to add `newItem` to the end of `original` instead of `push`. The function should return an array. </del> <ins> Change the `nonMutatingPush` function so it uses `concat` to merge `newItem` to the end of `original` without mutating `original` or `newItem` arrays. The function should return an array. </ins> # --hints--

Related discussion:
text: Since newItem, which references an array should be to the original array (per the instructions), I expected to pass the test. Instead it says "nonMutatingPush([1, 2, 3], [4, 5]) should return [1, 2, 3, 4, 5].", which would be concatenating the two arrays, but it isn't a non mutating alternative to as the instructions suggest. <img width="1437" alt="fcc-challenge" src="https://user-"<!-- Please complete the following information. --- Device: [laptop] OS: [macOS] Browser: [chrome] <!-- Add any other context about the problem here. --
the function should return (newItem). You put the newItem in an array literal, due to which the test is failing.
I see what you are saying. Really, the challenge is asking you to replicate the effect of using push with the spread operator. I'm not sure what change to the wording would make this clearer. Do you have any suggestions?
it also fails without literal syntax, e.g.: I know that it will pass when I write but this is the problem, because the instructions say: would result in arr having the value . So i suppose a function named "nonMutatingPush" should have a similar effect as push namely creating a "two dimensional"-Array in this case, like in the example in the instructions, and not do something entirely different (ie. merging the content of the two arrays into a new array)
The challenge doesn't say anything about using a spread operator, instead it asks users to "Change the nonMutatingPush function so it uses concat to add newItem to the end of original instead of push". Pushing an array to an array would produce an array in an array. Since "The concat() method is used to merge two or more arrays" () to replicate the effect of push one needs to put the array about to be "pushed" into a new array, so the outer array gets merged and the inner array stays intact. My suggestion would be, if replicating the push behaviour isn't the case, but merging the two given arrays, the instructions should ask users to "Change the nonMutatingPush function so it uses concat to merge newItem with original, without altering and "
Yeah makes sense to me.