How to update values inside an object using DOM/HTML related functions, such as onclick or addEventListener (Vanilla Javascript)

There is something about calling a function using DOM elements, such as button (onclick, addEventListener), and calling function by updating the Browser.

I am trying to change values of a key inside an object. When I do that using click on a button in HTML, the change does not sit permanently in the object – it is only relevant to that function (onclick, such as onlick or addEventListener).

But I want to be able to change the value on click of a button in HTML, so that I can use it in other functions.

How can I solve this issue?