Duplicate variables on stacked pages

I am using stacked pages which have variables for storing info. I am not sure if it matters but I append a child element with javascript for these variables as the page is initialized.
I am wondering if there is a way to reference variables within a page only, as the variables are overwriting each other as I add them.
I tried changing var to let to make them scoped, but it is complaining that the variables are already declared. I think the scope is within a function, not html element anyways.

I guess the question is can I have javascript variables within an html scope or is there something similar that I am not seeing for Dom7 pages ?