Switch widget: specify a range of values (instead of typing every value one by one)

Can you specify a range of values instead of typing each value one by one?

I don't want this:

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]

I want this (or something similar):

[1 to 20]

Thank you!

1 Like

Yes, with some javascript : arrays - Does JavaScript have a method like "range()" to generate a range within the supplied bounds? - Stack Overflow

2 Likes

Hmmm...

Result:

Just a thought here. Don't JS blocks return an empty string if you don't have a return statement?

Have you tried #{}?

1 Like

@GeneralMidi is right. Also, "_" is not defined, it's a 3rd party library called "lodash", there are other examples that don't require any library.

1 Like

The working example I found is this:

Array.from(new Array(*number of values*), (x, i) => i + *lowerBound*);

As @GeneralMidi said, #{} is needed here.

Thank you!