Trying to perform simple task of toggling a locally stored variable and missing something. I have the following logic under a button click:
var status = localStorage.getItem('sendLocation');
console.log('retrieved status =',status);
status = !status; // this is where the trouble arises
console.log('new status=',status);
localStorage.setItem('sendLocation',status);
When I look at console I see the following after clicking a few times -
retrieved status = true
new status= false
retrieved status = false
new status= false
retrieved status = false
new status= false
... and so on.
It is as though the ! option to toggle boolean is not interpreted correctly. It works once and then no more. This is the only code using the local storage var. Any ideas ?