# Anyone know how to join two arrays together?

**URL:** https://forum.makecode.com/t/anyone-know-how-to-join-two-arrays-together/17660
**Category:** Arcade
**Created:** [January 29, 2023, 11:56pm UTC](https://forum.makecode.com/t/anyone-know-how-to-join-two-arrays-together/17660 "2023-01-29T23:56:20Z")
**Posts on this page:** 1
**Showing post:** 15

<div class="post-metadata">

### Author: ![Sarge](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sarge/32/19590_2.png) [@Sarge](https://forum.makecode.com/u/Sarge)
#### Post date: [February 1, 2023, 7:04pm UTC](https://forum.makecode.com/t/anyone-know-how-to-join-two-arrays-together/17660/15 "2023-02-01T19:04:02Z")

</div>

I know it’s kind of late, but JavaScript has a convenient `Array.prototype.concat()` method. It returns a value without modifying the original array.  
Given `array1 = [1, 2] & array2 = [3, 4]`:

```auto
let array3 = array1.concat(array2);

```

‘array3’ will be defined as [1, 2, 3, 4]  
(this method is stackable, so you can do `array1.concat(array2).concat(array3)...`

* * *

In blocks you need to write your own method, as one is not in place. You could implement it something like this (pseudocode) :

```auto
function add_arrays(array1, array2)
    define new_array = array1
    for item in array do
        new_array.push(item)
    return new_array

```

Or alternatively (blocks) :

 ![example](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/5/5864094dda2702dccf5a39e42f6e8850ceda36f5.png)

---

_[View the full topic](https://forum.makecode.com/t/anyone-know-how-to-join-two-arrays-together/17660)._
