Conditionals execute certain code that meet specific conditions
if (someColor == blue) {
alert("The color is " + someColor);
} else {
alert("The color is not blue.")
}
Check multiple conditions
if (someColor == blue) {
alert("The color is blue.");
} else if (someColor == red) {
alert("The color is red.")
} else {
alert("The color is neither red nor blue.")
}
var x = y >= 0 ? y : -y;
Conditional expressions can be used as a function argument, statements cannot.
myFunction(y >= 0 ? y : -y)