How can i display a statement only once in a loop which is running 4 times?

Hi,

     I have the following code where i want to display the message "Hello World" only once in a loop . what condition i should write?


a!localVariables(

a!forEach(
                   items: {1,2,3,4},
                  expression:
                    {

                                   concat("Hello "," World")

                    }

              )
)

  Discussion posts and replies are publicly visible

Parents
  • In order to display a message once in a loop, first decide the condition for displaying a message. Then implement the condition inside the loop.

    For example, if I want to display the Hello World when I reach second iteration or item, follow the below code snippet

    a!forEach(
    items: { 1, 2, 3, 4 },
    expression: {
    if(
    fv!item = 2,
    concat("Hello ", " World"),
    null
    )
    }
    )

    To avoid null values in the results:

    reject(
    fn!isnull,
    a!forEach(
    items: { 1, 2, 3, 4 },
    expression: {
    if(
    fv!item = 2,
    concat("Hello ", " World"),
    null
    )
    }
    )
    )

Reply
  • In order to display a message once in a loop, first decide the condition for displaying a message. Then implement the condition inside the loop.

    For example, if I want to display the Hello World when I reach second iteration or item, follow the below code snippet

    a!forEach(
    items: { 1, 2, 3, 4 },
    expression: {
    if(
    fv!item = 2,
    concat("Hello ", " World"),
    null
    )
    }
    )

    To avoid null values in the results:

    reject(
    fn!isnull,
    a!forEach(
    items: { 1, 2, 3, 4 },
    expression: {
    if(
    fv!item = 2,
    concat("Hello ", " World"),
    null
    )
    }
    )
    )

Children