javascript - 我的代码有什么问题?

标签 javascript syntax

目前我正在研究函数,我无法真正找出以下代码有什么问题。 无论“密码”采用什么值,我总是得到“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/

相关文章:

javascript - JS : For loop continues to iterate after condition is false

javascript - 文本区域和选择器选项未发送到电子邮件

javascript - React 测试库 : The given element does not have a value setter when fireEvent change on input form

javascript - var functionName = function() {} vs function functionName() {}

javascript - 如何加载连续图像,直到图像不存在为止?

javascript - 使用jQuery触发html onclick事件

c++ - "int main(){(([](){})());}"如何是有效的 C++?

python - Jython 和 Python 的区别

mysql - 如何在 MySQL 脚本中透视单个表?

syntax - 构造者的困惑