Reputation: 37
Apologies for being so inept!
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`);
}
Here whatever i make the variable of population to be it seems to be ignored by the If statement and im not sure why!
Upvotes: 0
Views: 81
Reputation: 71
You could use and (&&) operator for that
if (language === "English" && population < 50 && isIsland === false) {
console.log(`You should live in ${country} :)`);
} else {
console.log(`${country} does not meet your criteria`);
}
Upvotes: 0
Reputation: 36490
"or" condition:
if (language === "English" || population < 50 || isIsland === false)
"and" condition
if (language === "English" && population < 50 && isIsland === false)
Upvotes: 0
Reputation: 3302
You are missing logical operator in if statement. Logical operators are use to test for true or false. There are three logical operators in JavaScript.
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`);
}
Upvotes: 1