The thing is, you never enter the "Every 10 seconds" event (you never stayed 10 full seconds for it to pop), but you do enter the "Every 1 second" event.
To keep data persistent, I'd suggest creating another variable and add 1 to it every 1 second. Then, if it's equals/bigger than 10, subtract 10 from it, and reduce 1 from a.
Save it in the localstorage as well, this should do the trick.