我正在尝试检查字符串是否为空、小于或等于 9 位或最多 10 位。但它始终遵循else if (str.length <= 9)
.
if (str = ''){
console.log("The string cannot be blank");
} else if (str.length <= 9) {
console.log("The string must be at least 9 characters long");
} else if (str.length <= 10) {
console.log("The string is long enough.");
}
无论我投入什么,我总是得到The string must be at least 9 characters long
。为什么?