Looping Through SubStruct

What’s the best way to loop through this counts substruct, returning the keys & values (courses, etc.) with only non-zero values?

and also pulling out the following structure’s sub-array data:

lucee_substructarray

Thanks!

have a look at structReduce()
https://docs.lucee.org/reference/functions/structreduce.html

https://trycf.com/gist/17ab3b32df8d19133545827fd8a03092/lucee5?theme=monokai

image.png

Thank you! That definitely worked for my data/counts struct.

Any suggestions for that struct > array > subarray?

Would structReduce still be effective?

There is also array reduce
https://docs.lucee.org/reference/functions/arrayreduce.html

reduce closures can return any data type, just pass in to initialValue