What does the ternary operator `condition ? a : b` evaluate to when condition is false?

JavaScript Professional Easy

JavaScript Professional — Easy

What does the ternary operator `condition ? a : b` evaluate to when condition is false?

Key points

  • The ternary operator returns the value of `a` if the condition is true
  • The ternary operator returns the value of `b` if the condition is false
  • It is a shorthand way of writing an if-else statement in JavaScript

Ready to go further?

Related questions