我是JavaScript的新手,我只是在学习基本的,不知道为什么只有一半的代码可以工作。
var quartet = ["abasd", "bsdfa", "ccvssw"];
console.log("quartet.length : " + quartet.length);
console.log(quartet[0]);
console.log(quartet[1]);
console.log(quartet[2]);
if (quartet.length = 1) {
console.log("It's just a Solo");
} else if (quartet.length = 2) {
console.log("It's just a Duo");
} else if (quartet.length = 3) {
console.log("It's just a Trio");
} else if (quartet.length = 4) {
console.log("Perfect, a quartet, just right");
} else {
console.log("Either too many or nobody");
};
for (var i = 0; i <= quartet.length; i++) {
console.log(quartet[i] + " : " + i)
};
但是,任何使此条件语句在 VS Code 内部工作的尝试都会导致
quartet.length : 3
abasd
bsdfa
ccvssw
It's just a Solo
abasd : 0
undefined : 1
守着星空守着你
萧十郎
相关分类