# Conditional Statements

Conditional statements allow you to run a bit of code if a certain condition is satisfied. Conditional statements are an important part of [structured programming](https://en.wikipedia.org/wiki/Structured_programming) and let us make much more dynamic software.

There are a number of [operators](/javascript/js-basics/operators.md#comparison-operators) that help use make certain conditions, and these conditions will result in a boolean value for us to evaluate.

NOTE: the assignment operator `=` is different to the conditional operator `==`. event though they look similar, the single one is for assigning values, and the double one is for comparing values.

consider the following code:

```
var userAge = window.prompt('How old are you?');

if (userAge >= 18) {
    alert('You are an adult');
} else {
    alert('you are legally a child');
}
```

Conditional statements make use of the if/else keywords to set up control flow.

If the condition inside the parenthesis next to the `if` keyword evaluate to `true`, then that block will run, otherwise the `else` block will run if present (you don't need to include an else block)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learning.pavey.dev/javascript/js-basics/conditional-statements.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
