# FAQ: Conditionals and Control Flow - Ternary Conditional

#1

This community-built FAQ covers the “Ternary Conditional” exercise from the lesson “Conditionals and Control Flow”.

Paths and Courses
This exercise can be found in the following Codecademy content:

## FAQs on the exercise Ternary Conditional

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

## Join the Discussion. Help a fellow learner on their journey.

Agree with a comment or answer? Like () to up-vote the contribution!

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

#2

why they mentioned ? mark in trenary operator

#3

its part of the ternary operator syntax:

``````condition ? true : false
``````
1 Like
#4

Is the ternary operator used often?

#5

Often is relative. But the ternary operator is certainly used.

#6

how come in the sample question they use char canDrive = (fuelLevel > 0) ? ‘Y’ : ‘N’;

I’m confused as to why it’s a char variable and not a boolean variable, or does this matter?

#7

`'y'` and `'n'` are characters, not boolean values. Which is why you use `char`

1 Like
#8

Often is relative. But the ternary operator is certainly used.

#9
``````char canDrive = (fuelLevel > 0) ? 'Y' : 'N';

``````

never met “?”, “:” those symbols together,
why instead of : we can’t use || (or) operator?

#10

A tenary is akin to an if…else statement.

``````if (x > ) {
y = 'Y'
} else {
y = 'N'
}
``````

This is not a logical expression, as such, and neither is a ternary.

``````variable = condition ? response_when_true : default_response;
``````

The nice thing about a ternary expression is it can be a single conditional assignment.