|
Conditional operator
- (condition) ? trueVal : falseVal
|
Assigns a specified value to a variable if a condition is true,
otherwise assigns an alternate value if condition is false.
Example:
preferredPet = (cats > dogs) ? "felines" : "canines"
- If (cats>dogs), preferredPet will be assigned
the string value "felines," otherwise it will be assigned
"canines".
|