I'm trying to check is localStorage value is correct. Localstorage value is successfully saved. I wonder why it always return false.
console.log('isTrue',localStorage.getItem('third') == "2") // false
console.log('value',localStorage.getItem('third')) // "2"
localStorage.setItem('third', JSON.stringify(third)) // save like this
Can someone help what is wrong? Thanks!
Check the API spec for local storage and the get/set methods, particularly the return type of .getItem - you'll need to JSON.parse the store value before doing comparisons between other data or doing other work with it, i.e.
console.log('isTrue', JSON.parse(localStorage.getItem('third')) === "2") --> true