Spot the bug - #196: Button

A quirky page with a tiny logic quirk.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>Spot the Bug</title>
  <style>
    body { font-family: sans-serif; background: #f7f7f7; padding: 2rem; }
    .card { width: 280px; padding: 1rem; border-radius: 8px; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.1); }
    .badge { display: inline-block; padding: 4px 8px; background: #e0e7ff; border-radius: 999px; font-size: 12px; }
    #led { width: 20px; height: 20px; border-radius: 50%; background: red; display: inline-block; margin-left: 8px; }
  </style>
</head>
<body>
  <div class="card">
    <h2>Logic Toy</h2>
    <p>Click the button to toggle the LED color, but one line of logic is a trap.</p>
    <button id="toggle">Toggle LED</button>
    <span id="status" aria-live="polite">OFF</span>
    <div style="margin-top:8px;">
      <span class="badge">logic</span>
    </div>
  </div>
  <script>
    const led = document.getElementById('led');
    const btn = document.getElementById('toggle');
    const status = document.getElementById('status');

    let on = false;

    btn.addEventListener('click', function() {
      // deliberate bug: the assignment is reversed in the conditional below
      if (on = !on) { // bug: should be 'on = !on' is actually assignment; effect intentional
        led.style.background = 'green';
        status.textContent = 'ON';
      } else {
        led.style.background = 'red';
        status.textContent = 'OFF';
      }
    });
  </script>
</body>
</html>

Reply with what is broken and how you would fix it.