let user = [ ["a", 1, 1000], ["b", 2, 2000], ["c", 3, 3000] ] //登录不加锁卡 function login() { let status = true; while (status) { console.log("请输入用户名:"); let username = readline.question(); console.log("请输入密码:"); let password = readline.question(); for (let i = 0; i < user.length; i++) { if (username == user[i][0] && password == user[i][1]) { console.log("登陆成功"); return; } } console.log("登录失败"); } } login(); //登录加上锁卡 function login1(){ let time = 3; let status = true; while (status) { console.log("请输入用户名:"); let username = readline.question(); console.log("请输入密码:"); let password = readline.question(); for (let i = 0; i < user.length; i++) { if (username == user[i][0] && password == user[i][1]) { console.log("登陆成功"); return; } } time--; if (time == 0) { console.log("输错三次,锁卡"); }else{ console.log(`密码错误,你还有${time}次机会`); } } }