我希望该功能在用户单击取消时停止,如果他们输入的数字不符合条件,则重新运行提示。现在,如果我输入的数字不符合条件,它将停止功能。这是怎么了?谢谢!
function findPasswordLength() {
passwordLength = prompt("Choose character length \n(at least 8 and no more than 128)");
if (passwordLength >= 8 && passwordLength <= 128) {
alert("Your password will be " + passwordLength + " characters long");
}
else if (passWordLength === null) {
return;
}
else if (typeof(passwordLength) !== "number" || passwordLength < 8 || passwordLength > 128) {
findPasswordLength();
}
}
您只是在变量名passwordLength
上有错字。
此
else if (passWordLength === null) {
实际上应该是
else if (passwordLength === null) {