What does the ternary operator return in: const x = 5 > 3 ? ‘yes’ : ‘no’?

JavaScript Associate Easy

JavaScript Associate — Easy

What does the ternary operator return in: const x = 5 > 3 ? ‘yes’ : ‘no’?

Key points

  • The ternary operator returns one of two values based on a condition.
  • In this case, since 5 is indeed greater than 3, the expression evaluates to 'yes'.
  • The syntax for the ternary operator is condition ? value if true : value if false.

Ready to go further?

Related questions