if
statementcondition ? expression that is run if condition is true : expression that is run if condition is false
const isLactoseIntolerant = true
const milkType = isLactoseIntolerant ? "almond" : "dairy"
console.log(milkType)
Rewrite the following if..else statement using a ternary operator:
let yearOfBirth = 2001
if (yearOfBirth <= 2002) {
console.log('you will be old enough to vote in 2020')
} else {
console.log('Sorry, you will not be old enough to vote next year')
}