πŸ“Š JavaScript
Q. Among the following, which one is a ternary operator?
  • (A) ?:
  • (B) -
  • (C) :
  • (D) +
πŸ’¬ Discuss
βœ… Correct Answer: (A) ?:

Explanation:

The ?: operator is known as the ternary operator, and it is a shorthand for an if-else statement. It takes three operands:

condition ? expression_if_true : expression_if_false;

For example:

let result = (x > 10) ? "Greater" : "Smaller";

This means that if x > 10 is true, result will be "Greater", otherwise, it will be "Smaller".

Explanation by: Praveen Singh

The ?: operator is known as the ternary operator, and it is a shorthand for an if-else statement. It takes three operands:

condition ? expression_if_true : expression_if_false;

For example:

let result = (x > 10) ? "Greater" : "Smaller";

This means that if x > 10 is true, result will be "Greater", otherwise, it will be "Smaller".

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
255
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Kirti
Publisher
πŸ“ˆ
98%
Success Rate