3 回答

TA貢獻(xiàn)1783條經(jīng)驗(yàn) 獲得超4個(gè)贊
您在 if 語(yǔ)句中缺少邏輯運(yùn)算符。邏輯運(yùn)算符用于測(cè)試真或假。JavaScript 中有三個(gè)邏輯運(yùn)算符。
和(&&)
或(||)
不是(?。?/p>
let country = "UK";
let language = "English";
let population = 60;
let isIsland = false;
if (language === "English" && population < 50 && isIsland === false) {
console.log(`You should live in ${country} :)`);
} else {
console.log(`${country} does not meet your criteria`);
}

TA貢獻(xiàn)1796條經(jīng)驗(yàn) 獲得超10個(gè)贊
“或”條件:
if (language === "English" || population < 50 || isIsland === false)
“和”條件
if (language === "English" && population < 50 && isIsland === false)

TA貢獻(xiàn)1825條經(jīng)驗(yàn) 獲得超6個(gè)贊
您可以為此使用 and (&&) 運(yùn)算符
if (language === "English" && population < 50 && isIsland === false) {
console.log(`You should live in ${country} :)`);
} else {
console.log(`${country} does not meet your criteria`);
}
添加回答
舉報(bào)