GlossaryFundamentals

What is a conditional?

A conditional is a statement that performs different actions based on whether a condition is true or false.

Conditionals allow programs to make decisions based on certain criteria. They help control the flow of execution by executing specific code when conditions are met.

For example, in JavaScript, you can use an if statement to check if a variable is true and run code accordingly. This is essential for creating dynamic and responsive applications.

Conditionals are often used in conjunction with loops and functions to create complex logic in your programs.

Example

if (age >= 18) { console.log('You can vote.'); }

Want to use Conditional in real work?

WeCode workshops are built around AI coding tools. Pick a tier, or browse more glossary entries to get the lay of the land.