Combine Two Arrays Using the concat Method

Combine Two Arrays Using the concat Method
0

#1

Tell us what’s happening:

What i’m doing wrong?

Your code so far


function nonMutatingConcat(original, attach) {
  // Add your code below this line
nonMutatingConcat([1, 2, 3], [4, 5]);

  
  // Add your code above this line
}
var first = [1, 2, 3];
var second = [4, 5];
nonMutatingConcat(first, second);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/functional-programming/combine-two-arrays-using-the-concat-method


#2

https://www.w3schools.com/jsref/jsref_concat_array.asp

original.concat(attached)


#3

function nonMutatingConcat(original, attach) {
// Add your code below this line
[1, 2, 3].concat([4, 5, 6]);

// Add your code above this line
}
var first = [1, 2, 3];
var second = [4, 5];
nonMutatingConcat(first, second);

This is my new code but the exercise tell me that
nonMutatingConcat([1, 2, 3], [4, 5]) should return [1, 2, 3, 4, 5].


#4

make sure your function has return then your answer

function nonMutatingConcat(original, attach){ return original.concat(attach); };

I always forget to do that. the syntax is correct though


#5

Use the arguments in the function and not the arrays as a whole.
Try solving now.


#6

function nonMutatingConcat(original, attach) {
// Add your code below this line
return original.concat(attach);

// Add your code above this line
}
var first = [1, 2, 3];
var second = [4, 5];
nonMutatingConcat(first, second);

This code is my solution.


#7

Thank you very much for helping .