DEV Community

Aaron
Aaron

Posted on

2 2

Conditional (ternary) operator in JavaScript

This video shows how you can refactor your existing function using an if statement to a ternary operator.

In our example we create a function that returns true or false based on whether the number has at least 2 digits in it. Initially we do this using an if statement and at the end of the video we show the power of a ternary operator by doing it in a single line.

Have a great weekend!

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up