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

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!

Hello,

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

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

oh it’s too complicated for me !!!

I did something old-fashioned:

``````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" }
}
}
`````` 3 Likes

Slightly less verbose…

``````function make_array() {
var start = 3;
var end = 10;
var arr = [];
while (start <= end) {
arr.push(start);
start++;
}
console.log(arr);
}
``````
``````[ 3, 4, 5, 6, 7, 8, 9, 10 ]
``````
4 Likes

Thanks!

I had put some parameters ``````function make_array(start,end) {
var arr = [];
while (start <= end) {
arr.push(start);
start++;
}
return arr;
}

return make_array(3,10)
``````

Saludos!

1 Like