3 回答

TA貢獻1783條經(jīng)驗 獲得超4個贊
您在 if 語句中缺少邏輯運算符。邏輯運算符用于測試真或假。JavaScript 中有三個邏輯運算符。
和(&&)
或(||)
不是(?。?/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貢獻1796條經(jīng)驗 獲得超10個贊
“或”條件:
if (language === "English" || population < 50 || isIsland === false)
“和”條件
if (language === "English" && population < 50 && isIsland === false)

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