I am building ATM project and storing user data in local storage but after then I collect data and loop on this to match an existing user or creating a new user the data I can get is not be able to convert on JSON
after getting data from local storage I can't be able to convert to JSON for looping the data.
function User(id,pin,amount) {
this.id = id,
this.pin = pin,
this.amount = amount
}
var memory = [];
function loginSignup(){
var id= document.querySelector('.card').value;
var pin= document.querySelector('.pass').value;
var user = new User(id,pin);
user = JSON.stringify(user);
memory.push(user);
localStorage.setItem('user', memory);
var localData = [];
localData.push(localStorage.getItem('user'));
console.log(localData);
}
for(var i=0; i<localstorage.length; i++){
if(localstorage[i].id == id){
only allow update }
else{ update new user}
Like this is for understanding I want to loop in local storage data that users enter.