dashen们这个咋写,一直报错,没有思路

dashen们这个咋写,一直报错,没有思路dashen们这个咋写,一直报错,没有思路

img


let persons = [
    {"username": "xiaoming", "password": 1111},
    {"username": "xiaoming2", "password": 2222},
    {"username": "xiaoming3", "password": 33333},
  ]
  let user1 = {"username": "admin", "password": 12345}
  let user2 = {"username": "administrator", "password": 12345}

  function signIn(user){
    persons.forEach(function(item){
      if(item.username == user.username ){
        if(item.password == user.password){
          console.log("用户已存在");
        }else {
          console.log("密码错误");
        }
      }else {
        console.log("用户不存在");
      }
    })
  }
  function signUp(user){
    persons.forEach(function(item){
      if(item.username == user.username ){
        console.log("用户已注册");
      }else {
        persons.push(user);
        console.log("注册成功");
      }
    })
  }
  signIn(user1);
  signUp(user1);
  signIn(user2);
  signUp(user2)
  console.log(persons)