Just use JSON.parse
:
localStorage.isAuthenticated = true;
if (localStorage.isAuthenticated && JSON.parse(localStorage.isAuthenticated )) {
//great
}
I use the &&
to check if the value is undefined. If localStorage.isAuthenticated returns undefined because it's not set, you get a false back.