Returning defined variables

Hello there,

I’m hoping to get some help.

My current automation uses an “increment” function to define variables (e.g. addon_1, addon_2) where the number within “addon_” is being handled by the increment function.

The goal is to create tailored JSON for use in a REST call.

Example of defined variables:

  • addon_1
  • addon_2

Basically, I want to return the “addon value” based on the iteration number. In example, if it is the second iteration, it should return the variable “addon_2” – ideal setup as in the screenshot.

That being said, I am not able to specify which variable I want it to return dynamically.

I’ve tried putting it in an array, but then I run into the issue of not being able to use “get()” to pull the raw name of the variable. That only works for objects. Tried creating a “Custom function” but I got quite stuck with that as JavaScript is not my forte.

Any best practices here?

Kind regards,