--- id: 587d7da9367417b2b2512b66 title: Combine Two Arrays Using the concat Method challengeType: 1 videoUrl: '' localeTitle: Combina dos matrices usando el método concat --- ## Description
Concatenation significa unir artículos de extremo a extremo. JavaScript ofrece el método concat para cadenas y matrices que funcionan de la misma manera. Para las matrices, el método se llama en una, luego se proporciona otra matriz como el argumento a concat , que se agrega al final de la primera matriz. Devuelve una nueva matriz y no muta ninguna de las matrices originales. Aquí hay un ejemplo:
[1, 2, 3] .concat ([4, 5, 6]);
// Devuelve una nueva matriz [1, 2, 3, 4, 5, 6]
## Instructions
Utilice el método concat en la función nonMutatingConcat para concatenar attach al final del original . La función debe devolver la matriz concatenada.
## Tests
```yml tests: - text: Su código debe utilizar el método concat . testString: 'assert(code.match(/\.concat/g), "Your code should use the concat method.");' - text: La first matriz no debe cambiar. testString: 'assert(JSON.stringify(first) === JSON.stringify([1, 2, 3]), "The first array should not change.");' - text: La second matriz no debe cambiar. testString: 'assert(JSON.stringify(second) === JSON.stringify([4, 5]), "The second array should not change.");' - text: 'nonMutatingConcat([1, 2, 3], [4, 5]) debe devolver [1, 2, 3, 4, 5] .' testString: 'assert(JSON.stringify(nonMutatingConcat([1, 2, 3], [4, 5])) === JSON.stringify([1, 2, 3, 4, 5]), "nonMutatingConcat([1, 2, 3], [4, 5]) should return [1, 2, 3, 4, 5].");' ```
## Challenge Seed
```js function nonMutatingConcat(original, attach) { // Add your code below this line // Add your code above this line } var first = [1, 2, 3]; var second = [4, 5]; nonMutatingConcat(first, second); ```
## Solution
```js // solution required ```