我怎样才能继续循环?

How can i continue while cycle?

用户正在输入 his/her 密码,直到输入正确为止。当用户想要单击 "Cancel" 时,我们会询问 "Are you sure?",如果答案是否定的,则再次询问密码。

我尝试再次使用 to strat 但它不起作用 =(


var password = "username",
    user_password        ,
    checked = true       ,
    user_password = prompt("Enter your password"),
    checked_confirm      ;

label: while(checked){
    if(user_password == password){
        alert("You are successfully logged in");
        break;
    }
    else if(user_password == null){
        checked_confirm =  confirm("Are you sure you want to cancel authorization?");
        if(checked_confirm){
            alert("You have canceled authorization");
            break;
        }
        else{
            continue lable;
        }
    }
    else{
        user_password = prompt("Enter your password");
    }
}

在循环开始时询问密码,不要破坏`直到你得到它:

var password = "username",
  user_password,
  checked_confirm;

while (true) {
  user_password = prompt("Enter your password");

  if (user_password == password) {
    alert("You are successfully logged in");
    break;
  } else if (user_password == null) {
    checked_confirm = confirm("Are you sure you want to cancel authorization?");
    if (checked_confirm) {
      alert("You have canceled authorization");
      break;
    }
  } else {
    alert("Wrong password");
  }
}