StoicBuilder

HandbookI the LudusOperators and comparisons

Ithe Ludus, Read code

Operators and comparisons

1 min readUpdated 28 November

In plain words

Operators are the symbols that do arithmetic, compare two values or combine conditions, and one wrong character can flip what your app decides.

Where you see it

Any line with an if in it leans on operators. In Guildhall, user.role === "admin" decides who sees the delete button, and && or || decides whether both checks must pass or only one.

src/components/MemberActions.tsxbrowser
const isAdmin = user.role === "admin";const isAuthor = post.authorId === user.id; // either one is enough to show the buttonconst canDelete = isAdmin || isAuthor;
=== asks whether two values are equal. || means either side can be true.

What goes wrong

  1. One equals sign where three were meant

    = stores a value and === compares. Inside an if, a single = sets the role and makes the check pass for everyone.

    if (user.role = "admin") { showAdminPanel(); }
  2. Using == instead of ===

    == converts types before comparing, so 0 == "" is true. === checks the type as well, which is nearly always what you want.

  3. Swapping && and ||

    "Admin and author" and "admin or author" are different rules. Two characters decide whether you lock everyone out or let everyone in.

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
Use === and !== for every comparison in this file, and never a single = inside a condition. Then explain each if statement back to me in one plain sentence.

Quick check

Sign in to earn +10 XP for it

Every Guildhall member can suddenly see the admin panel. Which line is the likely culprit?

Got a prompt that touches operators and comparisons?

Paste it. You get a better prompt first, then the cards that explain it.

Check your own prompt

Free, no sign-up.