Arrays and Nested Loops

I am trying to use an array and was wondering how I could add elements to the array as a user clicks on different elements on the page. I was also wondering how I could use a nested loop to run a loop for each element in the array. Thank you

Is there a custom widget to run a nested loop?

@aafahannah, there isn’t a widget for running nested loops, but you could use multiple looper widgets and write the logic such that, if the conditions you’re interested in are met, the output of LOOPER A gets passed to LOOPER B as many levels deep as necessary.

Thank you. I’m trying to create a situation where the loop runs on an array of arrays. Do you think this is possible?

I am trying to create a custom widget but I keep getting the error, “Uncaught ReferenceError: LoopList2 is not defined”, even though I have defined LoopList2 as: “const LoopList2 = ;”

Hey @aafahannah, if you want to create a widget for nested loops go for it! That said, it might just be easier to add two of the original looping widget to your app.

If you run into trouble feeding an initial array to your new parent array, try using the totext() function to convert each array you’d like to push to the parent to a string first.

Thank you. I’ll try this out with the original looping widget. Any idea how I can add elements to an array variable as a user clicks on them? I am currently displaying the elements using a single select widget with a menu display

I’d add a button and, in that button, add a trigger action that uses the ArrayPush onto Array action to add the element from the single select to an array. You could also put this trigger directly on the single-select widget.

Full list of array actions in triggers can be found here.