# \[Extension\] BetterArrays - 60 useful array blocks!

**URL:** <https://forum.makecode.com/t/extension-betterarrays-60-useful-array-blocks/29154>\
**Category:** Show & Tell\
**Tags:** extension\
**Created:** [June 7, 2024, 4:44pm UTC](https://forum.makecode.com/t/extension-betterarrays-60-useful-array-blocks/29154 "2024-06-07T16:44:30Z")\
**Posts on this page:** 20\
**Page:** 1

<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:** [June 7, 2024, 4:44pm UTC](https://forum.makecode.com/t/extension-betterarrays-60-useful-array-blocks/29154/1 "2024-06-07T16:44:30Z")

</div>

## Attention: this post is so big that it broke Discourse’s 32k character limit, so I had to split it into two parts. Part 2 will be posted in the replies. Please don’t reply until you see part 2 posted below.

Hello everyone, it’s ya boy with another extension. [Last time](https://forum.makecode.com/t/extension-stringify-convert-anything-to-strings/28585) I said I’d return with a bigger extension, so here I am, after 3 weeks of pouring digital blood, sweat and tears into this extension. This is by far the biggest extension I’ve ever created - adding 60 blocks with ~1300 lines of extension code and nearly as many lines of testing code.

So, you can expect this not only to be my biggest, but also most polished extension, as it’s been thoroughly (_questionable_) tested.

Before going any further, it’s important to clarify a few things. Firstly, this extension does **not** add a new category to the block toolbar. It just adds new blocks to the default `Arrays` category. In JavaScript, you can find the methods in the `arrays` namespace.

So, without further ado, let’s jump into it.

* * *

# Blocks

As you can see below, this extension adds two new groups to the Arrays category, “Checks” and “Mutual Operations” (they weren’t there before).

> **Create**
>
> The Create category contains blocks that create entirely new arrays from given values. BetterArrays adds **2** new blocks to it.
> 
> > **Repeat**
> >
> > The repeat method creates an array by repeating an element a given number of times. This behaviour is inspired by Python’s `[item]*repeat` syntax.
> > 
> > ```auto
> > function repeat(item: any, repeat: number): any[]
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/a/ad6109837a1e3ee3220da11b79d265916416e69d.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/8/8224c52b8a2c9ee9db1832fff5ea877cc3aaf4eb.png)
> > 
> > This example returns `["foo", "foo", "foo"]`
> > 
> > ### Exceptions
> > 
> > **NON\_INTEGER\_VALUE** is thrown if _repeat_ is not an integer  
> > **NEGATIVE\_VALUE** is thrown if _repeat_ is a negative number
> 
> > **Range**
> >
> > The range method creates a range of numbers starting from **start** , ending with **end** (not included) while increasing each value in the range by **step** (optional; default is 1)
> > 
> > ```auto
> > function range(start: number, end: number, step: number): number[]
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/6/6f3b8fc64a6e40de0eec48262f288a0acb341e24.png)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/6/6c639f9472f0d8d74685eea07290671b9407ce2a.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/8/80aa342c697cec0b6a6e2301aee3017accb05e32.png)
> > 
> > This example will return `[0, 1, 2, 3, 4]`
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/6/6c639f9472f0d8d74685eea07290671b9407ce2a.png)
> > 
> > This example will return `[0, 2, 4, 6, 8]`
> > 
> > ### Exceptions
> > 
> > **NON\_INTEGER\_VALUE** is thrown if _start_, _end_, or _step_ are not integers  
> > **NEGATIVE\_VALUE** is thrown if _step_ is a negative number  
> > **ZERO\_STEP** is thrown if _step_ is equal to 0  
> > **INVALID\_RANGE** is thrown if _end_ is lower than _start_

> **Read**
>
> The Read category contains blocks that read data from arrays. BetterArrays adds **9** new blocks to it.
> 
> > **Find Last**
> >
> > The findLast method returns the index of the last occurrence of an item in an array.  
> > Returns `-1` if the item is not found.
> > 
> > ```auto
> > function findLast(array: any[], item: any): number
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/5/5f4d4c4297e815077d7019c1ca5ecc7585696d25.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/optimized/2X/b/bb6923ad1bceb6dc1a2555a40a4b921e1ed3bd7f_2_690x45.png)
> > 
> > This example returns `2` (because the last occurrence of “foo” is at index 2)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/8/8c35d6e2069fa1475e0af0abdb895272cfccfdf3.png)
> > 
> > This example returns `-1` because “baz” is not in the array.
> 
> > **Find All**
> >
> > The findAll method returns an array of indicies pointing to every occurrence of an item. You can use **max** to limit the number of indicies that are retrieved (default is 0, which is unlimited).
> > 
> > ```auto
> > function findAll(array: any[], item: any, max: number): number[]
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/8/8092d055a481ad5b1b8b72d882bb68348e58c186.png)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/1/1f17f0e38cc3c6bf2216628916b0809e505ecc7e.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/optimized/2X/a/a2f3da9f394a8a9f56de0aec1a9f68969f44dcd6_2_690x45.png)
> > 
> > This example returns `[0, 2]` (because “foo” appears on indicies 0 and 2)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/optimized/2X/f/f46a186e7b0978a1b804d5ca31ae5ebd5f7f6aab_2_690x39.png)
> > 
> > This example returns `[0]` (because number of found indicies is limited to 1)
> > 
> > ### Exceptions
> > 
> > **NON\_INTEGER\_VALUE** is thrown if _max_ is not an integer  
> > **NEGATIVE\_VALUE** if _max_ is a negative number
> 
> > **Count**
> >
> > The count method counts the number of times an item occurs in an array.
> > 
> > ```auto
> > function count(array: any[], item: any): number
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/9/9146fb8aa5f818c65dc70293638bcc9f724a0755.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/optimized/2X/d/dcdc78c04eaf57e3e15e84c75f49ec71dc9344d5_2_690x47.png)
> > 
> > This example returns `2` (because “foo” occurs twice in the array)
> 
> > **Convert to string**
> >
> > The toString method converts an array to a string.
> > 
> > ```auto
> > function toString(array: any[]): string
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/5/53d64b4e153cd7dc9fa78f6de722ae085edd2fc0.png)
> 
> > **Random Index**
> >
> > The randomIndex method returns a random index from an array.
> > 
> > ```auto
> > function randomIndex(array: any[]): number
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/4/45d56818f28d694ba54cdc1b593534e2439ced35.png)
> > 
> > ### Exception
> > 
> > **EMPTY\_ARRAY** is thrown if _array_ is empty
> 
> > **Min Index**
> >
> > The minIndex method returns the index of the smallest element from a **number** array.
> > 
> > ```auto
> > function minIndex(array: number[]): number
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/a/a9f0018f0de02ca8a07e30a8a3a493ce087a0c6f.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/9/92ca3744fef734ce1beb96018d62a3fbf228c5ee.png)
> > 
> > This example returns `2` (2 is the index of the biggest element, 2)
> > 
> > ### Exceptions
> > 
> > **EMPTY\_ARRAY** is thrown if _array_ is empty
> 
> > **Min**
> >
> > The min method returns the smallest element from a **number** array.
> > 
> > ```auto
> > function min(array: number[]): number
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/0/0a593ac67f41ac71ce5be2df7e9b1e23ecdc6c59.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/5/54156ebeb4c793cbf1eeac6e452c573484975af9.png)
> > 
> > This example returns `2`
> > 
> > ### Exceptions
> > 
> > **EMPTY\_ARRAY** is thrown if _array_ is empty
> 
> > **Max Index**
> >
> > The maxIndex method returns the index of the biggest element from a **number** array.
> > 
> > ```auto
> > function maxIndex(array: number[]): number
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/2/296aeac7955e4127bb5be507341b5819401bd4b9.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/d/d1a47a01275db2aee2cbb6b9c0751042f0832396.png)
> > 
> > This example returns `1` (1 is the index of the biggest element which is 6)
> > 
> > ### Exceptions
> > 
> > **EMPTY\_ARRAY** is thrown if _array_ is empty
> 
> > **Max**
> >
> > The max method returns the biggest element from a **number** array.
> > 
> > ```auto
> > function max(array: number[]): number
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/a/a447181b4fe646a04cb97d06feed591032b7f99a.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/0/0abf719c81bd80020c74626fe3e893c22818b532.png)
> > 
> > This example returns `6`
> > 
> > ### Exceptions
> > 
> > **EMPTY\_ARRAY** is thrown if _array_ is empty

> **Modify**
>
> The Modify category contains blocks that modify arrays directly. BetterArrays adds **18** new blocks to it.
> 
> > **Remove All**
> >
> > The removeAll method removes all occurrences of **item** from an array. You can use **max** (default is 0, which is unlimited) to limit the number of items removed. This method modifies the original array.
> > 
> > ```auto
> > function removeAll(array: any[], item: any, max: number): void
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/8/86e84105b14ed28db8b1765148b225f7b70783bb.png)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/3/3800f7c8356bcfcbe26ec16be32b01802b4248db.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/7/7dec716034bc1c9b47d818c939c50c59ca956be3.png)
> > 
> > In this example _list_ becomes `["bar"]` (both “foo” elements are removed)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/3/3dcfcaa3128ded1f5d12b346d0b4558d724e3919.png)
> > 
> > In this example _list_ becomes `["bar", "foo"]` (the first and second “foo” are removed, leaving “bar” and the last “foo”)
> > 
> > ### Exceptions
> > 
> > **NON\_INTEGER\_VALUE** is thrown if _max_ is not an integer  
> > **NEGATIVE\_VALUE** is thrown if _max_ is negative
> 
> > **Swap**
> >
> > The swap method swaps items at **first** and **second** indicies in an array. This method modifies the original array.
> > 
> > ```auto
> > function swap(array: any[], first: number, second: number): void
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/1/17b8a614eec001e1ad8fcb999ad2d9093a4c5a26.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/7/7365da6ca3bba22df6dc60e18ac3da53d6c962f0.png)
> > 
> > In this example, _list_ becomes `["baz", "bar", "foo"]` (because the first and last items are swapped)
> > 
> > ### Exceptions
> > 
> > **NON\_INTEGER\_VALUE** is thrown if _first_ or _second_ are not integers  
> > **NEGATIVE\_VALUE** is thrown if _first_ or _second_ are negative  
> > **OUT\_OF\_RANGE** is thrown if _first_ or _second_ are out of _array_ range
> 
> > **Replace**
> >
> > The replace method replaces all elements in an array matching **item** with **replacement**. This method modifies the original array.
> > 
> > ```auto
> > function replace(array: any[], item: any, replacement: any): void
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/f/f92d85ed21dc52ee08202e8a3ad19a154f034f38.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/5/5fba1892d5824798a284131f6f9776ca275145d1.png)
> > 
> > In this example _list_ becomes `["bar", "bar", "baz"]` (“foo” is replaced with “bar”)
> 
> > **Fill**
> >
> > The fill method fills an item with a static **item** from a **start** (optional; default is 0) index to an **end** (optional; default is array lenght; end index is excluded) index. This method modifies the original array.
> > 
> > ```auto
> > function fill(array: any[], item: any, start: number, end: number): void
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/a/ab717c7b1038390f83ee1c9e3d274fcb34fa9ae4.png)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/6/6ad59d66ae417a876a336b014e0cd436ca818e90.png)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/a/ab6cd9e0c69c76bd1fb5291a16b0f1a31966b109.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/3/3adc3b15ad02626f35a0d6c5a357e5c15e2d1204.png)
> > 
> > In this example _list_ becomes `["bam", "bam", "bam"]` (array is completely filled)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/7/730e20780e2949b9a9a385b4512ac3a6b1782409.png)
> > 
> > In this example _list_ becomes `["foo", "bam", "bam"]` (filled from 1 to end)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/b/be94d82bfa1ee7de58d058e41b4dfce749b31cf0.png)
> > 
> > In this example _list_ becomes `["bam", "bam", "baz"]` (filled from 0 to 2, not including 2, so only items at indicies `0` and `1` are set)
> > 
> > ### Exceptions
> > 
> > **NON\_INTEGER\_VALUE** is thrown if _start_ or _end_ are not integers  
> > **NEGATIVE\_VALUE** is thrown if _start_ or _end_ are negative  
> > **OUT\_OF\_RANGE** is thrown if _start_ or _end_ are out of _array_ range  
> > **INVALID\_RANGE** is thrown if _end_ is smaller than _start_
> 
> > **Concatenate**
> >
> > The concat method concatenates (adds) a second array to the end of an array. This mehtod modifies the first array.
> > 
> > ```auto
> > function concat(first: any[], second: any[]): void
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/1/15e6971d280b4be4358fa628c00e13789520134b.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/8/844da6b26d7f9024b017f61104ee0d36902b77b9.png)
> > 
> > In this example _list_ becomes `["foo", "bar", "baz", "bam"]` (`["foo", "bar"]` + `["baz", bam"]` = `["foo", "bar", "baz", "bam"]`)
> 
> > **Slice**
> >
> > The slice extension slices an array from a **start** (optional; default is 0) index to an **end** (optional; default is array length; end index is excluded) index, with an optional **step** value. This method modifies the original array.
> > 
> > ```auto
> > function slice(array: any[], start: number, end: number, step: number): void
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/8/82bf909d508620da67854f079861d1d92c731153.png)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/0/00fcd7da47277f1e3f1006e83cbc36e675c73bed.png)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/c/c7b62ab1beaa00622da77eb6150dc1ec8bb73c1b.png)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/c/c860ad5e40804ba06a1e3d640f06c4632ae56e03.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/5/5a9e096354597e66e2ef1260f50091151f8d70ed.png)
> > 
> > In this example _list_ does not change its value (because the array is sliced from start to end. I’m not sure why this feature exists)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/d/d935b6f1e590ddfbb01df2ababa75e2d3deccdb7.png)
> > 
> > In this example _list_ becomes `["bar", "baz"]` (the list is sliced from index 1, leaving index 0 out)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/f/fae555bfc09840b9742930f3758f66dabe7e58fd.png)
> > 
> > In this example _list_ becomes `["foo", "bar"]` (the list is sliced from 0 to 2, where 2 is excluded, so “baz” is excluded)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/b/b15f2b51378a831aceb5a5e29c4270e49b9c0f9c.png)
> > 
> > In this example _list_ becomes `["foo", "baz"]` (starting at index 0, the method steps two elements forward to index 2, which gets “baz” and skips “bar”)
> > 
> > ### Exceptions
> > 
> > **NON\_INTEGER\_VALUE** is thrown if _start_, _end_ or _step_ are not integers  
> > **NEGATIVE\_VALUE** is thrown if _start_, _end_ or _step_ are negative  
> > **OUT\_OF\_RANGE** is thrown if _start_ or _end_ are out of list range  
> > **ZERO\_STEP** is thrown if _step_ is 0  
> > **INVALID\_RANGE** is thrown if _end_ is smaller than _start_
> 
> > **Zip**
> >
> > The zip method creates an array of pairs by grouping elements from two arrays. If the arrays are not the same length, excess items in the longer array will be ignored. This method modifies the first array.
> > 
> > ```auto
> > function zip(first: any[], second: any[]): void
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/c/c462ca106c53485e0644b8a89a6ae26ca3bd672b.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/f/f8be660d7b2bf4b9a74612e04d1dee7806d8b55d.png)
> > 
> > In this example _list_ becomes `[["foo", 1], ["bar", 2], ["baz", 3]]`
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/8/8c958c59369b443effa74f957181ed10405e8234.png)
> > 
> > In this example _list_ becomes `[["foo", 0], ["bar", 1]]` (3rd item is ignored because shorter array length is 2)
> 
> > **Clear**
> >
> > The clear method clears the array. This method modifies the original array.
> > 
> > ```auto
> > function clear(array: any[]): void
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/e/e99a6beda1cd4fe0702e606b6069f60471abf024.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/5/59c4e69227b6b23bae9c31c881e0ff7ca25d83c5.png)
> > 
> > In this example _list_ becomes `[]`
> 
> > **Union**
> >
> > The union method creates a union (all elements from both arrays together, no duplicates) from two arrays. This method modifies the first array.
> > 
> > ```auto
> > function union(first: any[], second: any[]): void
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/1/1c9cf570c8661c6dbe596fc55ef7fbfb76ded7dc.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/3/3087fe8be15df53a4566933de3ed49838a4e9988.png)
> > 
> > In this example _list_ becomes `["foo", "bar", "baz"]` (elements from both arrays, but with “bar” appearing once because it’s a duplicate)
> 
> > **Intersection**
> >
> > The intersection method creates an intersection (only elements that appear in both arrays, no duplicates) from two arrays. This method modifies the first array.
> > 
> > ```auto
> > function intersection(first: any[], second: any[]): void
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/0/0bf4fc3a8940ed49a7c657a0fd52f910894ab3f5.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/6/634325cad0b093730fab6964421d85bf2cb85fdf.png)
> > 
> > In this example _list_ becomes `["bar"]` (only “bar” is in both arrays)
> 
> > **Difference**
> >
> > The difference method creates a difference (elements that appear in the first array, without the items from the second array) from two arrays. This method modifies the first array.
> > 
> > ```auto
> > function difference(first: any[], second: any[]): void
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/0/0cb59d6ff63b949a7047038a1e6e1241f5a0208b.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/4/4a9b117383d8f228b4a977150badd6639beca02c.png)
> > 
> > In this example _list_ becomes `["foo"]` (“bar” is removed because it’s also in the second array)
> 
> > **Purge (Remove Duplicates)**
> >
> > The purge method removes duplicate elements from an array. This method modifies the original array.
> > 
> > ```auto
> > function purge(array: any[]): void
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/a/abf9a661ecbff440cdc41a753f4fe94ce2dd3c2c.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/5/55edb80b4ce864d4932470c6e3e149bc452578fc.png)
> > 
> > In this example _list_ becomes `["foo", "bar"]` (the duplicate “foo” is removed)
> 
> > **Sort**
> >
> > The sort method sorts a number array in ascending or descending order. String arrays may be supported in the future. This method modifies the original array.
> > 
> > ```auto
> > function sort(array: number[], order: SortOrder): void
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/e/ef26fe5ccb81fe87cdd1b58a69fbb248202d78bb.png)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/b/bcf6c488b7918f8cb0b99d403c21744c5cbc94a8.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/2/2c1cac76a30d4a075b84e748e4e89d7bfa2676fe.png)
> > 
> > In this example _list_ becomes `[1, 2, 3]`
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/4/46b7f0d800fc95cf6a5854f5d1d9b64d214a5a8c.png)
> > 
> > In this example _list_ becomes `[3, 2, 1]`
> 
> > **Enumerate**
> >
> > The enumerate method enumerates elements of an array (creates value-index pairs). This method modifies the original array.
> > 
> > ```auto
> > function enumerate(array: any[]): void
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/9/9d9a257a5e22ebbf7c0ca22ad6e7ed5b53141ad4.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/3/3fd663e259482ca5ddf3480f2520b5a705bc83c8.png)
> > 
> > In this example _list_ becomes `[["foo", 0], ["bar", 1], ["baz", 2]` (value-index pairs from array)
> 
> > **Splice**
> >
> > The splice method deletes **count** elements from **start** index in an array. This method modifies the original array.
> > 
> > ```auto
> > function splice(array: any[], start: number, count: number): void
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/b/bd06c6c945d6754dd1fc54097aeec1c7f8ffa7ef.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/e/e4e457f2b8ec011f0b1c69569c91a85f81766bc0.png)
> > 
> > In this example _list_ becomes `[1]` (2 elements starting from 0 were removed)
> > 
> > ### Exceptions
> > 
> > **NON\_INTEGER\_VALUE** is thrown if _start_ or _count_ are not integers  
> > **NEGATIVE\_VALUE** if _start_ or _count_ are negative
> 
> > **Unzip**
> >
> > The unzip method extracts elements from an array of pairs, at **target** index. This method modifies the original array.
> > 
> > ```auto
> > function unzip(array: any[][], target: number): void
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/e/ec77ff5a33ac42120005ae31bf742904d98eb64f.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/7/7176ffd608dab87f8aba7a8822d63661099c28dc.png)
> > 
> > In this example _list_ will become `["a", "b"]` (Gets index 0 from every pair)
> > 
> > ### Exceptions
> > 
> > **NON\_INTEGER\_VALUE** is thrown if _target_ is not an integer  
> > **NEGATIVE\_VALUE** if _target_ is negative  
> > **NOT\_ARRAY** if element to unpack is not an array (every element must be an array)  
> > **OUT\_OF\_RANGE** if target index is bigger than pair length
> 
> > **Shift**
> >
> > The shift method shifts all elements in the array backwards by **elements**. This method modifies the original array.
> > 
> > ```auto
> > function shift(array: any[], elements: number): void
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/2/24399521308e9cb8193445046fbfd9e8f1478fbb.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/8/89796f4116b89b49c6d0cc204822d0fd99406830.png)
> > 
> > In this example _list_ becomes `[2, 3]`
> > 
> > ### Exceptions
> > 
> > **NON\_INTEGER\_VALUE** is thrown if _elements_ is not an integer  
> > **NEGATIVE\_VALUE** is thrown if _elements_ is negative  
> > **INVALID\_SHIFT** is thrown if _elements_ is bigger than _array_ length
> 
> > **Flatten**
> >
> > The flatten method unpacks arrays within an array recursively to the surface level up to a **max** depth value (default is 0, which is unlimited). This method modifies the original array.
> > 
> > ```auto
> > function flatten(array: any[], max: number): void
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/9/98ad79347cdd06b3d57b47ff19940962a3882ccc.png)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/9/98918ddfe55171385b1cfa6a2d5319522c89c476.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/6/6a84d4fe256fcc2eec9100343cae32debc136aa6.png)
> > 
> > In this example, _list_ becomes `[1, 2, 3, 4]`
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/4/4b55acfff7b62a4be40f8a9b4d1b9b5b386cd608.png)
> > 
> > In this example _list_ becomes `[1, 2, [3, 4]]` (because it only unpacks the first layer)
> > 
> > ### Exceptions
> > 
> > **NON\_INTEGER\_VALUE** is thrown if _max_ is not an integer  
> > **NEGATIVE\_VALUE** is thrown if _max_ is negative

> **Operations**
>
> The Operation category contains blocks that perform various operations on arrays, without modifying the original array. BetterArrays adds **21** new blocks to it.
> 
> > **To Shifted**
> >
> > The toShifted method (equivalent to shift) returns a copy of the array with all elements in the array shifted backwards by **elements**. This mehod does **not** modify the original array.
> > 
> > ```auto
> > function toShifted(array: any[], elements: number): void
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/8/8993a907d65ba1989ea6f0da200b73a1308b9c74.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/a/a8a7442db3c2c958e579281ef802217b313beffa.png)
> > 
> > This example returns `["bar", "baz"]`
> > 
> > ### Exceptions
> > 
> > **NON\_INTEGER\_VALUE** is thrown if _elements_ is not an integer  
> > **NEGATIVE\_VALUE** is thrown if _elements_ is negative  
> > **INVALID\_SHIFT** is thrown if _elements_ is bigger than _array_ length
> 
> > **Concatenate Many**
> >
> > The concatMany returns a concatenation (addition) of an array of arrays. This method does **not** modify the original array.
> > 
> > ```auto
> > function concatMany(arrays: any[][]): any[]
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/6/6487572f78200c8057344a67f4a062fca17facd4.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/0/019165f2d9dc2513931498244b0c1b3c58700fd4.png)
> > 
> > This example returns `[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]`
> 
> > **Zip Many**
> >
> > The zipMany method returns an array of pairs by grouping elements from multiple arrays. If the arrays are not the same length, excess items in the longer array(s) will be ignored.
> > 
> > ```auto
> > function zipMany(arrays: any[]): any[][]
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/0/06eabab2e3a3561a79f407e31dad0222b5528332.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/7/77604edf15f035527660043d493c33791bfd86b8.png)
> > 
> > This example returns `[[1, 4, 7, 10], [2, 5, 8, 11], [3, 6, 9, 12]]`
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/optimized/2X/f/f21a220fee30d9f04baea63e8fd3d3e718807a68_2_690x47.png)
> > 
> > This examples `[["a", 0], ["b", 1]]` (3rd element is ignored because shortest array has length 2)
> 
> > **To Flattened**
> >
> > The toFlattened method (equivalent to flatten) returns a copy of an array with arrays within unpacked recursively to the surface level up to a **max** depth value (default is 0, which is unlimited). This method does **not** modify the original array.
> > 
> > ```auto
> > function toFlattened(array: any[], max: number): any[]
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/4/4bc8786c164a5a59fd3a7e3006d7a4c7722bc864.png)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/a/a356739373a2eba3ebfd45f942af8ac903bcf3b6.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/optimized/2X/7/76e7953da39558b5e4a68a3fcfde1fd0c58c9a26_2_690x51.png)
> > 
> > This example returns `[1, 2, 3, 4]`
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/optimized/2X/0/09b742d47eafa4b4f1711c0494d2726aebf94034_2_690x43.png)
> > 
> > This example returns `[1, 2, [3, 4]]`
> > 
> > ### Exceptions
> > 
> > **NON\_INTEGER\_VALUE** is thrown if _max_ is not an integer  
> > **NEGATIVE\_VALUE** is thrown if _max_ is negative
> 
> > **Copy**
> >
> > The copy method returns a copy of the array (new array with same items). This method does **not** modify the original array.
> > 
> > ```auto
> > function copy(array: any[]): void
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/7/7a18df7f90c3102926a1092f51f5007708ef3d27.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/6/667954c38d97577fd1f5c71de843724cc3bdb0a2.png)
> > 
> > This example returns `["foo", "bar"]` (who could have predicted that?)
> 
> > **To Removed All**
> >
> > The toRemovedAll method returns an array copy with all occurrences of **item** removed. You can use **max** (default is 0, which is unlimited) to limit the number of items removed. This method does **not** modify the original array.
> > 
> > ```auto
> > function toRemovedAll(array: any[], item: any, max: number): any[]
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/b/baa3067d0bc2dbdaad20eb325d646d28d57e391d.png)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/f/f666d46d6557d9f8e8b507c50a85fa98eff4cb8f.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/optimized/2X/b/bd423af411a2bf5476c4e5c53f5ecfbd1f4b8cc3_2_690x44.png)
> > 
> > This example returns `["bar"]`
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/optimized/2X/d/dd729bf42bb9f4ef2ecbcb9078aef7075a71f70a_2_690x38.png)
> > 
> > This example returns `["bar", "foo"]` (second “foo” is not removed because max is 1)
> > 
> > ### Exceptions
> > 
> > **NON\_INTEGER\_VALUE** is thrown if _max_ is not an integer  
> > **NEGATIVE\_VALUE** is thrown if _max_ is negative
> 
> > **To Swapped**
> >
> > The toSwapped method returns an array copy with swapped items at **first** and **second** indicies. This method does **not** modify the original array.
> > 
> > ```auto
> > function toSwapped(array: any[], first: number, second: number): any[]
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/b/b444766ac3e1a4f7ab590c53d30f8a91f279d0d9.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/optimized/2X/b/bca663c5fca779bdbfdaf84a21b8675d2a1df272_2_690x47.png)
> > 
> > This example returns `["baz", "bar", "foo"]`
> > 
> > ### Exceptions
> > 
> > **NON\_INTEGER\_VALUE** is thrown if _first_ or _second_ are not integers  
> > **NEGATIVE\_VALUE** is thrown if _first_ or _second_ are negative  
> > **OUT\_OF\_RANGE** is thrown if _first_ or _second_ are out of _array_ range
> 
> > **To Replaced**
> >
> > The toReplaced method returns an array copy with all elements matching **item** replaced with **replacement**. This method does **not** modify the original array.
> > 
> > ```auto
> > function toReplaced(array: any[], item: any, replacement: any): any[]
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/a/a92b8602de32b6e744fa4a83a9a86c6cf168454e.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/optimized/2X/7/766c0e6792f990aa286d02d33e8369bfa8e6f773_2_690x37.png)
> > 
> > This example returns `["baz", "bar", "baz"]`
> 
> > **To Filled**
> >
> > The toFilled method returns an array copy filled with a static **item** from a **start** (optional; default is 0) index to an **end** (optional; default is array lenght; end index is excluded) index. This method does **not** modify the original array.
> > 
> > ```auto
> > function toFilled(array: any[], item: any, start: number, end: number): any[]
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/e/edcf2a86f30c337952e595311bd6c2e366133644.png)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/0/0d0c6afe12786ef1f4c97d611bdc049dc15ac67f.png)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/3/3caa3b28b4a4f31d647673e78ed177f6395205ab.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/4/49df02e51ecf54dade0a26df88a67956d81da73a.png)
> > 
> > This example returns `["bam", "bam", "bam"]`
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/optimized/2X/e/e6f410ed677f5fd3471413429b32c3e8b135bd89_2_690x44.png)
> > 
> > This example returns `["foo", "bam", "bam"]`
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/optimized/2X/a/a94fdaec1fea7e80369097d6b689805fc4b6ff52_2_690x42.png)
> > 
> > This example returns `["bam", "bam", "baz"]`
> > 
> > ### Exceptions
> > 
> > **NON\_INTEGER\_VALUE** is thrown if _start_ or _end_ are not integers  
> > **NEGATIVE\_VALUE** is thrown if _start_ or _end_ are negative  
> > **OUT\_OF\_RANGE** is thrown if _start_ or _end_ are out of _array_ range  
> > **INVALID\_RANGE** is thrown if _end_ is smaller than _start_
> 
> > **To Sliced**
> >
> > The toSliced method returns a slice of an array from a **start** (optional; default is 0) index to an **end** (optional; default is array length; end index is excluded) index, with an optional **step** value. This method does **not** modify the original array.
> > 
> > ```auto
> > function toSliced(array: any[], start: number, end: number, step: number): any[]
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/2/2203b026c8b2edede7e7f20b20e7c9d893398799.png)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/1/1f53114420f970a89010acf24ba89d1374ae58bd.png)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/e/eea4ed8a0b22761b49d9ae85573fa193cae97fa0.png)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/a/a1142cb562a1cde887883b4f7813be1d53618bf6.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/8/8692b78f55761550fafadfc4dd0d589f802df0ff.png)
> > 
> > This example returns `["foo", "bar", "baz"]` (for some reason)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/b/bbcbb8fe62163601b0098ee3882708ccf6375cb2.png)
> > 
> > This example returns `["bar", "baz"]`
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/optimized/2X/b/b4e6ce67a3d3aadd6256554c4a7de72b80579788_2_690x47.png)
> > 
> > This example returns `["foo", "bar"]` (index 2 is excluded)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/optimized/2X/8/8b9f1a9ef9297f550b441597884c733f64748690_2_690x40.png)
> > 
> > This example returns `["foo", "baz"]`
> > 
> > ### Exceptions
> > 
> > **NON\_INTEGER\_VALUE** is thrown if _start_, _end_ or _step_ are not integers  
> > **NEGATIVE\_VALUE** is thrown if _start_, _end_ or _step_ are negative  
> > **OUT\_OF\_RANGE** is thrown if start or end are out of list range  
> > **ZERO\_STEP** is thrown if _step_ is 0  
> > **INVALID\_RANGE** is thrown if _end_ is smaller than _start_
> 
> > **To Zipped**
> >
> > The toZipped method returns an array of pairs created from two arrays. If the arrays are not the same length, excess items in the longer array will be ignored.
> > 
> > ```auto
> > function toZipped(first: any[], second: any[]): any[][]
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/5/5ab902257360f6ba3f876f8e03c4bc23b4987a4d.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/optimized/2X/5/59742ee7a8a40f67e46ace3fbd3397e7b5a8b17e_2_690x41.png)
> > 
> > This example returns `[["foo", 1], ["bar", 2], ["baz", 3]]`
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/optimized/2X/0/0debb61bc4668a0b307d4ab8c6194b62952356ab_2_690x43.png)
> > 
> > This example returns `[["foo", 1], ["bar", 2]]` (3rd element from first array is ignored because second array length is 2)
> 
> > **To Reversed**
> >
> > The toReversed method returns a reversed copy of an array.
> > 
> > ```auto
> > function toReversed(array: any[]): any[]
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/d/d13c16514402261f019e0fdddb4a411b5cc1909e.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/8/89ffa74faedffa05c76ae9c1fe8a4d38f17fa42b.png)
> > 
> > This example returns `["baz", "bar", "foo"]`
> 
> > **For Each**
> >
> > The forEach method loops through an array with _value_ and _index_ parameters. You can drag any blocks into the handler to execute them within the loop using the parameters.
> > 
> > ```auto
> > function forEach(array: any[], handler: (value: any, index: number) => void): void
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/5/581c3a59a0f45a29e5b19b2ced651e15ba25f9e1.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/2/261d3f2cb7687d8954a3ce8523b7414944564a9f.png)
> > 
> > This example logs  
> > `0 = foo`  
> > `1 = bar`  
> > `2 = baz`  
> > to the console
> 
> > **To Purged**
> >
> > The toPurged method returns an array copy with all duplicates removed.
> > 
> > ```auto
> > function toPurged(array: any[]): any[]
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/7/7a8ac11c16329ec1993ea615791e0ca6afcc4531.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/f/f69f6a6a9eb646721ec5d7fe83c80f650fa112d3.png)
> > 
> > This example returns `["foo", "bar"]`
> 
> > **Extract**
> >
> > The extract method returns an array comprised of every occurrence of an **item** in an array.
> > 
> > ```auto
> > function extract(array: any[]): any[]
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/2/2f44dd41cb3f9ba8d6d0c7a4f6faeed03c726fb7.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/3/39f2065f859c69c56685b743d870b1e2eafb3d1f.png)
> > 
> > This example returns `["foo", "foo"]` (the first and last element are extracted from the original array and returned in a new array)
> 
> > **To Sorted**
> >
> > The toSorted method returns a sorted number array copy in ascending or descending order. String arrays may be supported in the future. This method does **not** modify the original array.
> > 
> > ```auto
> > function toSorted(array: number[], order: SortOrder): number[]
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/5/59798da3325a7ee26a20c99392aa346dcadb7424.png)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/6/62c5e55bbbebd4cdc47f1f1fea366a150b20ad8e.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/9/9ef401f36945116c1819e4f6ecdd1ff09716edab.png)
> > 
> > This example returns `[1, 2, 3]`
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/6/67083b72f5bf249735fa708a638301f1e224ea12.png)
> > 
> > This example returns `[3, 2, 1]`
> 
> > **Sum**
> >
> > The sum method returns a sum of elements in a number array.
> > 
> > ```auto
> > function sum(array: number[]): number
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/9/9826e66d4eb14b71a3a3b62c04372c015a44875f.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/f/f2139db5ae5f67bc9e198925451b9c86f9967b10.png)
> > 
> > This example returns `6`
> 
> > **To Enumerated**
> >
> > The toEnumerated method returns enumerated elements of an array (creates value-index pairs). This method does **not** modify the original array.
> > 
> > ```auto
> > function toEnumerated(array: any[]): any[]
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/f/fef7c6a140c372b990ce6a3480e0f52f421c2de9.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/6/6d7995a91b6018ca9e489c0ae70549a2715cbac0.png)
> > 
> > This example returns `[["foo", 0], ["bar", 1], ["baz", 2]]`
> 
> > **Join**
> >
> > The join method returns a string array joined into a single string using a **separator** (optional; default is nothing).
> > 
> > ```auto
> > function join(array: string[]): string
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/a/af44e7f98e16c79c99403cde74cc5b2215742a1c.png)
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/9/90aa28387f7cb2b9ddf2b79e8f5d618f5678b4e9.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/e/ed99c2e4b87de0b37c01083e858022386509d0d7.png)
> > 
> > This example returns `foobarbaz`
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/8/8a11a44e9819ea5828e37fb5a687d8c711a53683.png)
> > 
> > This example returns `foo-bar-baz`
> 
> > **To Spliced**
> >
> > The toSpliced method returns an array copy with **count** elements deleted from **start** index. This method does **not** modify the original array.
> > 
> > ```auto
> > function toSpliced(array: any[], start: number, count: number): any[]
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/6/6c97d57511404c7e766cad2dd94ed5ff919a1b12.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/optimized/2X/e/e3cb785ff8eb9fafeae2f028a3ba3d7403277605_2_690x45.png)
> > 
> > This example returns `["baz"]`
> > 
> > ### Exceptions
> > 
> > **NON\_INTEGER\_VALUE** is thrown if _start_ or _count_ are not integers  
> > **NEGATIVE\_VALUE** is thrown if _start_ or _count_ are negative  
> > **OUT\_OF\_RANGE** is thrown if _start_ is out of _array_ range
> 
> > **To Unzipped**
> >
> > The toUnzipped method returns extracted elements from an array of pairs, at **target** index. This method does **not** modify the original array.
> > 
> > ```auto
> > function toUnzipped(array: any[], target: number): any[]
> > 
> > ```
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/5/5144f8bd78834853151703aa0878b82e59b7e937.png)
> > 
> > ### Examples
> > 
> > ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/optimized/2X/6/69094d9a2237dba3199935a92a6dbe53789798c5_2_690x39.png)
> > 
> > This example returns `["foo", "bar"]` (extracts every element at index 0)
> > 
> > ### Exceptions
> > 
> > **NON\_INTEGER\_VALUE** if _target_ is not an integer  
> > **NEGATIVE\_VALUE** if _target_ is negative  
> > **NOT\_ARRAY** if element to unpack is not an array (every element must be an array)  
> > **OUT\_OF\_RANGE** if _target_ is bigger than pair length

---

<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:** [June 7, 2024, 7:06pm UTC](https://forum.makecode.com/t/extension-betterarrays-60-useful-array-blocks/29154/2 "2024-06-07T19:06:12Z")

</div>

> **Checks**
>
> The Checks category (new category) contains blocks that return true or false based on a condition inside of an array. BetterArrays adds **7** blocks to it.
> 
> > **Equal**
> >
> > The equal method returns true if two arrays are equal (regular javascript equality operation does not work on arrays, for some reason)
> > 
> > ```auto
> > function equal(first: any[], second: any[]): boolean
> > 
> > ```
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > ### Examples
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > This example does **not** return `true`, because _javascript_.
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > This example returns `true` (as it should)
> 
> > **In Range**
> >
> > The inRange method returns true if **index** is in range (between 0 and array length) of array.
> > 
> > ```auto
> > function inRange(array: any[], index: number): boolean
> > 
> > ```
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > ### Examples
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > This example returns `true` (0 \< 1 \< 2 is true)
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > This example returns `false` (0 \< 2 \< 2 is false)
> > 
> > ### Exceptions
> > 
> > **NON\_INTEGER\_VALUE** if _index_ is not an integer
> 
> > **Includes**
> >
> > The includes method returns true if **item** is included in an array.
> > 
> > ```auto
> > function includes(array: any[], item: any): boolean
> > 
> > ```
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > ### Examples
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > This example returns `true`
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > This example returns `false`
> 
> > **Is Empty**
> >
> > The isEmpty method returns true if an array is empty (length is 0).
> > 
> > ```auto
> > function isEmpty(array: any[]): boolean
> > 
> > ```
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > ### Examples
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > This example returns `true`
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > This example returns `false`
> 
> > **All True**
> >
> > The allTrue method returns true if all elements in an array evaluate to true.
> > 
> > ```auto
> > function allTrue(array: any[]): boolean
> > 
> > ```
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > ### Examples
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > This example returns `true`
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > This example returns `false` (0 evaluates to false)
> 
> > **Any True**
> >
> > The anyTrue method returns true if any element in an array evaluates to true.
> > 
> > ```auto
> > function anyTrue(array: any[]): boolean
> > 
> > ```
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > This example returns `true` (only true evaluates to true, but that’s enough to return true)
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > This example returns `false` (all elements evaluates to false)
> 
> > **All Equal**
> >
> > The allEqual method returns true if every element in an array is equal to **item**.
> > 
> > ```auto
> > function allEqual(array: any[], item: any): boolean
> > 
> > ```
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > ### Examples
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > This example returns `true`
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > This example returns `false`

> **Mutual operations**
>
> The Mutual Operations category (new category) contains blocks that perform operations comparing elements of two arrays and return the result. BetterArrays adds **3** blocks to it.
> 
> > **To Union**
> >
> > The toUnion method returns a union (all elements from both arrays together, no duplicates) of two arrays. This method does **not** modify the first array.
> > 
> > ```auto
> > function toUnion(first: any[], second: any[]): any[]
> > 
> > ```
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > ### Examples
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > This example returns `["foo", "bar", "baz"]`
> 
> > **To Intersection**
> >
> > The toIntersection method returns an intersection (only elements that appear in both arrays, no duplicates) of two arrays. This method does **not** modify the first array.
> > 
> > ```auto
> > function toIntersection(first: any[], second: any[]): any[]
> > 
> > ```
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > ### Examples
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > This example returns `["baz"]`
> 
> > **To Difference**
> >
> > The toDifference method returns a difference (elements that appear in the first array, without the items from the second array) of two arrays. This method does **not** modify the first array.
> > 
> > ```auto
> > function toDifference(first: any[], second: any[]): any[]
> > 
> > ```
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > ### Examples
> > 
> > ![image](https://sea2.discourse-cdn.com/flex020/images/transparent.png)
> > 
> > This example returns `["foo"]`

* * *

# Exceptions

As you can gather from the blocks chapter (see above), some blocks have an _exceptions_ category. This category describes which exceptions a block can throw, and under which condition that can occur.

BetterArrays throws exceptions for illegal values to make debugging easier and prevent unexpected behaviour. Below is an explanation of each of those exceptions.

> **NON\_INTEGER\_VALUE**
>
> This exception is thrown if a given **value** is not an integer (whole number)  
> Certain values (mostly indicies) cannot be decimal values
> 
> > Value must be integer (not [value])

> **NEGATIVE\_VALUE**
>
> This exception is thrown if a given **value** is negative  
> Certain values (mostly indicies) cannot be lower than 0
> 
> > Value must not be negative (not [value])

> **OUT\_OF\_RANGE**
>
> This exception is thrown if a given **value** is not within an **array** range  
> Values used for accessing values within an array must not be outside of array bounds
> 
> > Index ([value]) must be in list range (0, [array length; excluded])

> **ZERO\_STEP**
>
> This exception is thrown if a **step** value is equal to 0  
> Stepping values cannot be 0, as it would cause an infinite loop
> 
> > Stepping value cannot be 0

> **INVALID\_RANGE**
>
> This exception is thrown if an **end** value is lower than a **start** value  
> Start values must be lower than end values in order to create a valid range
> 
> > Start value ([start]) must be lower than end value ([end])

> **EMPTY\_ARRAY**
>
> This exception is thrown if a given **array** is empty  
> Certain methods require arrays containing at least one element
> 
> > Operation cannot be performed on empty array

> **NOT\_ARRAY**
>
> This exception is thrown if a given **value** type is not array  
> Certain methods expect elements to be an array type
> 
> > Expected array type (not [typeof value])

> **INVALID\_SHIFT**
>
> This exception is thrown if a **shift** value is bigger than an **array** length  
> The shift and toShifted methods can throw this exception
> 
> > Shift value ([shift]) cannot be bigger than array length ([length of array])

* * *

# Hardware Support

@danger_kitty pointed out that this extension (because it’s so huge) could take up too much device storage, making this extension unusable for projects that are intended for hardware ports.

After testing this theory, it was discovered that adding this extension to an empty project increases the compiled file size by a **whopping 0.4%**! Therefore, we can conclude that this extension can be used for hardware games as well.

* * *

And that’s the BetterArrays extension! I’ve sank a lot of my time making this extension, both writing code, and this post. If you find this useful, smash like and star the repo, would appreciate. If you found a mistake in this post, or unexpected behaviour in the extension, please let me know. Also be sure to submit any feature requests/ideas, as I’m open to adding new stuff!

Import the extension here

> **[GitHub - sargedev/betterarrays: Extension that adds many useful utility array...](https://github.com/sargedev/betterarrays)**
>
> Extension that adds many useful utility array methods

Now, I’m going to take a _very long_ nap. Peace ✌

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [June 7, 2024, 7:09pm UTC](https://forum.makecode.com/t/extension-betterarrays-60-useful-array-blocks/29154/3 "2024-06-07T19:09:10Z")

</div>

@Sarge MakeCode’s compiler is actually really smart about only compiling code that is actually used in your project. This is called [tree shaking](https://en.wikipedia.org/wiki/Tree_shaking).

As such, it’s totally possible to make huge extensions but not add that much to the compiled binary! Only the code that is actually referenced in the project will make it in.

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [June 7, 2024, 9:36pm UTC](https://forum.makecode.com/t/extension-betterarrays-60-useful-array-blocks/29154/4 "2024-06-07T21:36:52Z")

</div>

Lovely extension! This will make our lives a lot easier!

~~Waiting for BetterStrings now 🫠~~

---

<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:** [June 7, 2024, 9:37pm UTC](https://forum.makecode.com/t/extension-betterarrays-60-useful-array-blocks/29154/5 "2024-06-07T21:37:00Z")

</div>

So anyway pictures in part 2 dissapeared because discourse processes images in a goofy way so I’ll be posting those here soon, sorry for the inconvenience

---

<div class="post-metadata">

**Author:** ![Luke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/luke/32/32519_2.png) [@Luke](https://forum.makecode.com/u/Luke)\
**Post date:** [June 7, 2024, 9:46pm UTC](https://forum.makecode.com/t/extension-betterarrays-60-useful-array-blocks/29154/6 "2024-06-07T21:46:49Z")

</div>

Lets goooo!!!

---

<div class="post-metadata">

**Author:** ![Josef](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/josef/32/12457_2.png) [@Josef](https://forum.makecode.com/u/Josef)\
**Post date:** [June 7, 2024, 11:59pm UTC](https://forum.makecode.com/t/extension-betterarrays-60-useful-array-blocks/29154/7 "2024-06-07T23:59:34Z")

</div>

zNEW WORLD RECORD. he broke discourse.

---

<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:** [June 9, 2024, 4:33am UTC](https://forum.makecode.com/t/extension-betterarrays-60-useful-array-blocks/29154/8 "2024-06-09T04:33:09Z")

</div>

Uhhh @richard why is this block appearing as a square block and not a round one?

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/c/c94455f768e8288834ba13e2714511b72c9c7cfd.png)

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/2/2ef605bc383d23af107f9c81266793c51cf4ae33.png)

---

<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:** [June 9, 2024, 1:34pm UTC](https://forum.makecode.com/t/extension-betterarrays-60-useful-array-blocks/29154/9 "2024-06-09T13:34:20Z")

</div>

Nevermind, I am an idiot, the concat and toConcated blocks had the same id -.-

---

<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:** [June 13, 2024, 4:12pm UTC](https://forum.makecode.com/t/extension-betterarrays-60-useful-array-blocks/29154/10 "2024-06-13T16:12:39Z")

</div>

📢 **1.2.0 update** (yes, there have been minor updates I didn’t announce)  
Changelog:

- Added new `shuffle` and `toShuffled` methods (certainly not related to [the upcoming jam](https://forum.makecode.com/t/announcement-makecode-arcade-mini-game-jam-20-board-game-jam/29077)) 🤭
- Fixed minor issues and updated dependencies

## Shuffle method

The shuffle method rearranges items in an array in a random order. This method modifies the original array.

```auto
function shuffle(array: any[]): void

```

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/8/859bb10e49f226d367f5f2b3db021593735a3af0.png)

## To shuffled method

The toShuffled method returns an array copy with items rearranged in a random order. This method does **not** modify the original array.

```auto
function toShuffled(array: any[]): any[]

```

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/6/6dc38168de35e991735bb42ce0837a5342483f46.png)

Until next time, peace ✌

---

<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:** [July 23, 2025, 2:26am UTC](https://forum.makecode.com/t/extension-betterarrays-60-useful-array-blocks/29154/11 "2025-07-23T02:26:42Z")

</div>

📢 Just an announcement, patch 1.2.2 is out, if you needed to use methods on image or tile arrays and they weren’t working, now they do. Make sure to update the extension in your projects. See ya

---

<div class="post-metadata">

**Author:** ![BotWarrior](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/botwarrior/32/25328_2.png) [@BotWarrior](https://forum.makecode.com/u/BotWarrior)\
**Post date:** [July 23, 2025, 12:49pm UTC](https://forum.makecode.com/t/extension-betterarrays-60-useful-array-blocks/29154/12 "2025-07-23T12:49:29Z")

</div>

Would a tile map saving extension be possible? 👀  
Also I love this extension! As someone who has done a bit of python, I enjoy what you can do with arrays (not necessarily how messy it is). It is a bit of a niche extension for most users, and I just thought of a very good way to use it in one of my games.

---

<div class="post-metadata">

**Author:** ![BlueYoshi507](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/blueyoshi507/32/32630_2.png) [@BlueYoshi507](https://forum.makecode.com/u/BlueYoshi507)\
**Post date:** [March 12, 2026, 4:54pm UTC](https://forum.makecode.com/t/extension-betterarrays-60-useful-array-blocks/29154/13 "2026-03-12T16:54:04Z")

</div>

Hi @Sarge!!! I’m trynna do something:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/6/4/642b47560e8991cc56abb9fa04280189909db3ef.png)  
Is it possible to make it so for example: if in my list, index 0 and 2 have the highest value (eg: 30), then the pink sprites will say their index. So, like, the first pink one says 0, and the second one says 2.

---

<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:** [March 15, 2026, 9:12pm UTC](https://forum.makecode.com/t/extension-betterarrays-60-useful-array-blocks/29154/14 "2026-03-15T21:12:27Z")

</div>

There’s actually a block for this, it’s the `find occurrences of _ in list` block. Basically, first you should find out what the actual biggest value in the array is with the `biggest element in list` is and then just return an array of indices where that value is located in the list.

Something like this:

 ![arcade-screenshot](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/5/0/50923a5141f9c816d95dc0119fc2a7de1cfded6d.png)

In this case, the “value” variable actually represents and index, because the find occurrences block returns an array of indices (in this case [2, 4] because that’s where the biggest elements are at)

---

<div class="post-metadata">

**Author:** ![TheEarth](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/theearth/32/34579_2.png) [@TheEarth](https://forum.makecode.com/u/TheEarth)\
**Post date:** [April 12, 2026, 3:07am UTC](https://forum.makecode.com/t/extension-betterarrays-60-useful-array-blocks/29154/15 "2026-04-12T03:07:48Z")

</div>

Why does nothing show up in the arrays spot in js I’m just looking for the code snippets and they don’t exist would love if you added them in

---

<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:** [April 15, 2026, 9:36pm UTC](https://forum.makecode.com/t/extension-betterarrays-60-useful-array-blocks/29154/16 "2026-04-15T21:36:03Z")

</div>

I thought those were rendered automatically… I don’t actually know how to implement them if that’s not the case. However you can just type `arrays.` and hit tab to see every function available

---

<div class="post-metadata">

**Author:** ![TheEarth](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/theearth/32/34579_2.png) [@TheEarth](https://forum.makecode.com/u/TheEarth)\
**Post date:** [April 15, 2026, 9:37pm UTC](https://forum.makecode.com/t/extension-betterarrays-60-useful-array-blocks/29154/17 "2026-04-15T21:37:21Z")

</div>

Oh yesh I forgot dot operators exist

---

<div class="post-metadata">

**Author:** ![YamJam](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/yamjam/32/29681_2.png) [@YamJam](https://forum.makecode.com/u/YamJam)\
**Post date:** [July 28, 2026, 2:31am UTC](https://forum.makecode.com/t/extension-betterarrays-60-useful-array-blocks/29154/18 "2026-07-28T02:31:21Z")

</div>

@sarge , is there a way to convert a stringified list back into a list? I need this for a game I’m making.

---

<div class="post-metadata">

**Author:** ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)\
**Post date:** [July 28, 2026, 2:37am UTC](https://forum.makecode.com/t/extension-betterarrays-60-useful-array-blocks/29154/19 "2026-07-28T02:37:16Z")

</div>

That’s a string function, not an array function. Use the `split` block in the `Text` drawer.

---

<div class="post-metadata">

**Author:** ![VoxelMaster64](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/voxelmaster64/32/32075_2.png) [@VoxelMaster64](https://forum.makecode.com/u/VoxelMaster64)\
**Post date:** [July 28, 2026, 9:04pm UTC](https://forum.makecode.com/t/extension-betterarrays-60-useful-array-blocks/29154/20 "2026-07-28T21:04:56Z")

</div>

> [@Sarge](#):
>
> This example returns `2` (2 is the index of the biggest element, 2)

is that a typo?

[Next page](https://forum.makecode.com/t/extension-betterarrays-60-useful-array-blocks/29154.md?page=2)
