# Experimental Code - return an array of numbers between two values

**URL:** https://community.glideapps.com/t/experimental-code-return-an-array-of-numbers-between-two-values/32035
**Category:** Ask for Help
**Created:** [September 20, 2021, 8:57am UTC](https://community.glideapps.com/t/experimental-code-return-an-array-of-numbers-between-two-values/32035 "2021-09-20T08:57:19Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![benmitchell](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/benmitchell/32/13820_2.png) [@benmitchell](https://community.glideapps.com/u/benmitchell)
#### Post date: [September 20, 2021, 8:57am UTC](https://community.glideapps.com/t/experimental-code-return-an-array-of-numbers-between-two-values/32035/1 "2021-09-20T08:57:19Z")

</div>

Hi I’m looking for help to use the xc column to get an array of the range of numbers between two numbers e.g. Value 1: 6 to Value 2:11  
Which would return:  
6, 7, 8, 9, 10, 11

Any help much appreciated!

---

<div class="post-metadata">

### Author: ![Manu.n](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/manu.n/32/11679_2.png) [@Manu.n](https://community.glideapps.com/u/Manu.n)
#### Post date: [September 20, 2021, 9:16am UTC](https://community.glideapps.com/t/experimental-code-return-an-array-of-numbers-between-two-values/32035/2 "2021-09-20T09:16:56Z")

</div>

Hello,  
have you already done a few things or you want a ready-made solution

---

<div class="post-metadata">

### Author: ![benmitchell](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/benmitchell/32/13820_2.png) [@benmitchell](https://community.glideapps.com/u/benmitchell)
#### Post date: [September 20, 2021, 9:21am UTC](https://community.glideapps.com/t/experimental-code-return-an-array-of-numbers-between-two-values/32035/3 "2021-09-20T09:21:48Z")

</div>

I’ve had a go with the below code but not really getting anywhere.

```auto
 const range = (start, end) => {
 const length = end - start;
    return Array.from({ length }, (_, i) => start + i);

```

---

<div class="post-metadata">

### Author: ![Manu.n](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/manu.n/32/11679_2.png) [@Manu.n](https://community.glideapps.com/u/Manu.n)
#### Post date: [September 20, 2021, 9:24am UTC](https://community.glideapps.com/t/experimental-code-return-an-array-of-numbers-between-two-values/32035/4 "2021-09-20T09:24:30Z")

</div>

oh it’s too complicated for me !!!

I did something old-fashioned:

```auto
FILE function.js
window.function = function (num1, num2) {

  if (num1 === undefined) return;
  if (num2 === undefined) return;

  num1 = num1.value ?? 0;
  num2 = num2.value ?? 0;
  
  let ret = [];

  let x = num1;
  let y = num2;

  if (y < x)
  {
    x = num2;
    y = num1;
  }

  for (let i = x; i <= y; i++) {
    ret.push(i);
  }

  return ret;
  
}

FILE glide.json :
{
  "kind": "column",
  "name": "Date1to2",
  "description": "Date 1 to 2",
  "author": "Manu",
   "params": [
    {
      "name": "num1",
      "displayName": "Number 1",
      "type": "number"
    },
    {
      "name": "num2",
      "displayName": "Number 2",
      "type": "number"
    }
  ],
  "result": {
    "type": { "kind": "array", "items": "number" }
  }
}

```

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/6/1/61e449bae7744605cfffd3052abdf73d66c9bd0e.png)

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [September 20, 2021, 9:36am UTC](https://community.glideapps.com/t/experimental-code-return-an-array-of-numbers-between-two-values/32035/5 "2021-09-20T09:36:47Z")

</div>

Slightly less verbose…

```auto
function make_array() {
  var start = 3;
  var end = 10;
  var arr = [];
  while (start <= end) {
    arr.push(start);
    start++;
  }
  console.log(arr);
}

```

```auto
[3, 4, 5, 6, 7, 8, 9, 10]

```

---

<div class="post-metadata">

### Author: ![benmitchell](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/benmitchell/32/13820_2.png) [@benmitchell](https://community.glideapps.com/u/benmitchell)
#### Post date: [September 20, 2021, 9:38am UTC](https://community.glideapps.com/t/experimental-code-return-an-array-of-numbers-between-two-values/32035/6 "2021-09-20T09:38:40Z")

</div>

Thanks!

---

<div class="post-metadata">

### Author: ![gvalero](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gvalero/32/1037_2.png) [@gvalero](https://community.glideapps.com/u/gvalero)
#### Post date: [September 20, 2021, 12:49pm UTC](https://community.glideapps.com/t/experimental-code-return-an-array-of-numbers-between-two-values/32035/7 "2021-09-20T12:49:18Z")

</div>

> [@Darren\_Murphy](#):
>
> ```auto
> function make_array() {
> var start = 3;
> var end = 10;
> var arr = [];
> while (start <= end) {
> arr.push(start);
> start++;
> }
> console.log(arr);
> }
> 
> ```

I had put some parameters 🤓

```auto
function make_array(start,end) {
  var arr = [];
  while (start <= end) {
    arr.push(start);
    start++;
  }
  return arr;
}

return make_array(3,10)

```

Saludos!

---

<div class="post-metadata">

### Author: ![NoCodeAndy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nocodeandy/32/62530_2.png) [@NoCodeAndy](https://community.glideapps.com/u/NoCodeAndy)
#### Post date: [January 17, 2024, 4:50pm UTC](https://community.glideapps.com/t/experimental-code-return-an-array-of-numbers-between-two-values/32035/8 "2024-01-17T16:50:28Z")

</div>


