# Problem with arrays

**URL:** https://forum.makecode.com/t/problem-with-arrays/23832
**Category:** Help
**Created:** [November 1, 2023, 7:44pm UTC](https://forum.makecode.com/t/problem-with-arrays/23832 "2023-11-01T19:44:58Z")
**Posts on this page:** 1
**Showing post:** 12

<div class="post-metadata">

### Author: ![Vegz78](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/vegz78/32/1201_2.png) [@Vegz78](https://forum.makecode.com/u/Vegz78)
#### Post date: [November 6, 2023, 7:16pm UTC](https://forum.makecode.com/t/problem-with-arrays/23832/12 "2023-11-06T19:16:19Z")

</div>

Hi @Sarge,

I was trying to add two arrays together without using 2 loops and still keep the original array intact(copy).

I found out from one of your earlier posts that this was possible with concat():

> [@Anyone know how to join two arrays together?](https://forum.makecode.com/t/anyone-know-how-to-join-two-arrays-together/17660/15):
>
> 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]: 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) : function add\_arrays…

Still, I have not found out how to do this with only blocks/without grey blocks…

Here, illustrated with the functions AddList\_loop(), AddList\_no\_lopp() and AddList\_reference(), which are 2 loops, concat and same as yours above, respectively:

> **[ListAdd](https://arcade.makecode.com/55041-60792-68848-28261)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

As you can see, in the last one - AddList\_reference() and the same as yours above -, _result_ seems only to be a reference to _array1_ via the parameter _list1_, and the original _array1_ is overwritten.

---

_[View the full topic](https://forum.makecode.com/t/problem-with-arrays/23832)._
