Global variable?

Hi all, I would like to know how to define a kind of custom global variable that is accesible (to read and change) from inside and outside the scope of a for loop?

Here’s a post whith a few options for how to do this :

https://community.hubspot.com/t5/CMS-Development/How-to-change-a-variable-outside-of-a-for-loop-Scoping-Issues/td-p/211117

thank you