Add string to list items that are not empty

Consider I have a list with several items, some have data and others are empty. For example:

List
[0] Value
[1]
[2]
[3] Value

I would like to concatenate a string ONLY in the list items that are not empty, so I can get a result like this:

List
[0] Value StringAdded
[1]
[2]
[3] Value StringAdded

How can I do this? Thanks.

A simple conditional is all you need.

  1. Check all values.
  2. If empty string, return value.
  3. If not empty, add string and return value.

myVal == "" ? myVal : myVal + add;

3 Likes

Thanks. So simple with just one code block. I’ll have to learn more about code blocks!