2 回答
TA贡献1799条经验 获得超8个赞
TA贡献1815条经验 获得超13个赞
您应该使用 而不是 来比较数字。此外,条件应为 :而不是:===for loopi < quartet.lengthi <= quartet.length
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)
};
添加回答
举报