I am trying to maintain state in my objects and my work does not allow node.js.
You cannot write to a local computer file system using JS (i.e. to a text file as you say in your original question.)
However, you can write to a persistent object,
localStorage, which will allow you to store information between sessions. Like so:
This information persists betweens sessions, so you can later call
getItem to retrieve information:
localStorage.getItem('key') // === 'value'
This way, you could store information in the local browser. Not all browsers support this - for more information, check the MDN.