Loop for a specified number of times

Hi,

Is it possible to loop through a piece of code a specified number of times, based on an input value? i.e. if we wanted to simply repeat hello world based on a number entered into custom.some.thing:

{% input custom.some.thing placeholder:"Input value" as:"integer" %}
hello world

When custom.some.thing = 2, then…

hello world
hello world

…and so forth?

Many thanks
Joe

@jhanley

Thank you for your question.
You can try with below code:

{% input custom.some.thing placeholder:"Input value" as:"integer" %}

{% if custom.some.thing != blank %}
  {% for item in (1..custom.some.thing) %}
    Hello world
  {% endfor %}
{% endif %}

If you are interested, you can find more information here

1 Like

Hi @Jelena_Sutova,

Thanks for sharing your insight + resource. This has helped me further develop my code and provided a solution to my original query!

Kind regards
Joe