# Conditionals

By [AlchemyUniversity非公式和訳置き場](https://paragraph.com/@alchemyuniversity) · 2023-01-13

---

In programming it's often necessary to write code that depends on some **condition** to be true.

プログラミングでは、ある条件が真であることが必要な場合にコードを書くことがよくあります。

.

For a good example, let's imagine we're building a website!

良い例として、ウェブサイトを構築しているとしましょう！

.

We want users to be sent to the dashboard **only if** they are logged in. **Otherwise** we should send them to the login page:

ユーザーがログインしている場合にのみダッシュボードに転送し、そうでなければログインページに転送する必要があります：

.

    if(loggedIn) {
        // loggedIn is true
        goToDashboard();
    }
    else {
        // loggedIn is false
        goToLogin();
    }
    

.

You could think of this logic as: _If the user is logged in, then send them to the dashboard. If not, send them to the login page._

このロジックは、ユーザーがログインしている場合はダッシュボードに送信し、そうでなければログインページに送信すると考えることができます。

.

Our logic is **branched** based on the condition of whether or not the user is **logged in**. We can look at this from the perspective of a flow chart:

私たちのロジックは、ユーザーがログインしているかどうかの条件に基づいて分岐されます。これをフローチャートの観点から見ることができます：

.

![](https://storage.googleapis.com/papyrus_images/807ba715b8466a5f6500d016347dd5a9047db6294996864b2634e71b39956afa.png)

.

Ready to start coding your own conditionals? Let's get into it!

独自の条件を書き始める準備はできましたか？さあ始めましょう！

.

.

.

NEXT ⇒⇒

---

*Originally published on [AlchemyUniversity非公式和訳置き場](https://paragraph.com/@alchemyuniversity/conditionals)*
