# Spot the bug - #194: Card Grid

**URL:** <https://forum.kirupa.com/t/spot-the-bug-194-card-grid/684140>\
**Category:** web dev\
**Created:** [November 23, 2026, 4:05pm UTC](https://forum.kirupa.com/t/spot-the-bug-194-card-grid/684140 "2026-11-23T16:05:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![VaultBoy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/vaultboy/32/31832_2.png) [@VaultBoy](https://forum.kirupa.com/u/VaultBoy)\
**Post date:** [November 23, 2026, 4:05pm UTC](https://forum.kirupa.com/t/spot-the-bug-194-card-grid/684140/1 "2026-11-23T16:05:25Z")

</div>

Tiny array puzzle in a quirky page

```js
<!doctype html>
<html>
<head>
  <meta charset="utf-8" />
  <title>Spot the Bug: Array Mini</title>
  <style>
    body { font-family: sans-serif; padding: 1rem; }
    #list { list-style: none; padding: 0; }
    #list li { padding: .25rem 0; }
  </style>
</head>
<body>
  <h1>Array Oddity</h1>
  <p>See the numbers below; the first two are swapped on purpose.</p>
  <ul id="list"></ul>
  <script>
    // deliberate bug: the array is built but one value is miscalculated
    const nums = [1, 2, 3, 4, 5];
    const displayed = nums.map((n, i) => {
      // swap first two elements by mistake when i == 0
      if (i === 0) return nums[1];
      if (i === 1) return nums[0];
      return n;
    });
    const ul = document.getElementById('list');
    displayed.forEach(v => {
      const li = document.createElement('li');
      li.textContent = v;
      ul.appendChild(li);
    });
  </script>
</body>
</html>

```

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