I am trying to use an array map for checking if same username and password exist in an object array
database.map((obj)=>{ if(values.name === obj.name && values.password===obj.password){ console.log("login success"); } else { console.log("login Failed"); } });
Advertisement
Answer
You may use find for conditions:
const result = database.find((val)=> { return val.name === obj.name && val.password === obj.password; }) if(result){ console.log("login success"); } else{ console.log("login failed"); }