--- id: 587d7da9367417b2b2512b66 title: Combine Two Arrays Using the concat Method challengeType: 1 videoUrl: '' localeTitle: Combine duas matrizes usando o método concat --- ## Description
Concatenation significa unir itens de ponta a ponta. O JavaScript oferece o método concat para cadeias de caracteres e matrizes que funcionam da mesma maneira. Para matrizes, o método é chamado em um, em seguida, outro array é fornecido como o argumento para concat , que é adicionado ao final do primeiro array. Ele retorna um novo array e não altera os arrays originais. Aqui está um exemplo:
[1, 2, 3] .concat ([4, 5, 6]);
// Retorna uma nova matriz [1, 2, 3, 4, 5, 6]
## Instructions
Use o método concat na função nonMutatingConcat para concatenar attach ao final do original . A função deve retornar o array concatenado.
## Tests
```yml tests: - text: Seu código deve usar o método concat . testString: 'assert(code.match(/\.concat/g), "Your code should use the concat method.");' - text: O first array não deve mudar. testString: 'assert(JSON.stringify(first) === JSON.stringify([1, 2, 3]), "The first array should not change.");' - text: O second array não deve mudar. testString: 'assert(JSON.stringify(second) === JSON.stringify([4, 5]), "The second array should not change.");' - text: 'nonMutatingConcat([1, 2, 3], [4, 5]) deve retornar [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 ```