目前我正在研究函数,我无法真正找出以下代码有什么问题。 无论“密码”采用什么值,我总是得到“NICE”
var passValid = function (password) {
return password.length;
};
if (passValid<5){
console.log("ERROR");
}
else{
console.log("NICE");
}
passValid("somevalue");
最佳答案
我想你想要:
if (passValid("password") < 5) {
console.log("ERROR");
}
else {
console.log("NICE");
}
我不知道如何描述为什么你的原始代码是错误的;它只是在杂草丛中:-)
关于javascript - 我的代码有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13476205/