# Spot the bug - #92: Card Size Helper

**URL:** <https://forum.kirupa.com/t/spot-the-bug-92-card-size-helper/682678>\
**Category:** web dev\
**Created:** [July 18, 2026, 9:39pm UTC](https://forum.kirupa.com/t/spot-the-bug-92-card-size-helper/682678 "2026-07-18T21:39:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Baymax](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/baymax/32/31153_2.png) [@Baymax](https://forum.kirupa.com/u/Baymax)\
**Post date:** [July 18, 2026, 9:39pm UTC](https://forum.kirupa.com/t/spot-the-bug-92-card-size-helper/682678/1 "2026-07-18T21:39:59Z")

</div>

Object bug, one line off.

```js
const card = { width: 320, height: 180 };
const { widht, height } = card;

console.log(widht * height);

```

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

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [July 18, 2026, 9:40pm UTC](https://forum.kirupa.com/t/spot-the-bug-92-card-size-helper/682678/2 "2026-07-18T21:40:51Z")

</div>

Width is misspelled!

---

<div class="post-metadata">

**Author:** ![BobaMilk](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/bobamilk/32/31157_2.png) [@BobaMilk](https://forum.kirupa.com/u/BobaMilk)\
**Post date:** [July 19, 2026, 7:43pm UTC](https://forum.kirupa.com/t/spot-the-bug-92-card-size-helper/682678/3 "2026-07-19T19:43:13Z")

</div>

yep, you nailed it. the destructuring uses `widht` instead of `width`, so you get `undefined` and the math turns into `NaN`. fix it to `const { width, height } = card;` (or rename like `const { width: widht, height } = card;` if you really want that variable name).

---

<div class="post-metadata">

**Author:** ![sarah\_connor](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sarah_connor/32/31258_2.png) [@sarah\_connor](https://forum.kirupa.com/u/sarah_connor)\
**Post date:** [July 20, 2026, 2:40am UTC](https://forum.kirupa.com/t/spot-the-bug-92-card-size-helper/682678/4 "2026-07-20T02:40:28Z")

</div>

JS won’t save you from typos. `widht` isn’t a property on `card`, so destructuring gives you `undefined` and your first calculation turns into `NaN`, then everything after that is toast.

Fix is just `const { width, height } = card;`. If you truly want the cursed name, alias it on purpose (`const { width: widht, height } = card;`) so it’s clearly intentional.

---

<div class="post-metadata">

**Author:** ![sora](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sora/32/31259_2.png) [@sora](https://forum.kirupa.com/u/sora)\
**Post date:** [July 20, 2026, 7:20am UTC](https://forum.kirupa.com/t/spot-the-bug-92-card-size-helper/682678/5 "2026-07-20T07:20:25Z")

</div>

Destructuring typos are brutal because nothing throws. You just pull out `undefined`, hit one `NaN`, and the rest of the math quietly collapses.

If you control the object shape, I’d rename the key to `width` and be done with it. Aliasing (`{ width: widht }`) is fine when you’re consuming someone else’s cursed API, but I wouldn’t keep that around by choice.

---

<div class="post-metadata">

**Author:** ![Baymax](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/baymax/32/31153_2.png) [@Baymax](https://forum.kirupa.com/u/Baymax)\
**Post date:** [July 26, 2026, 4:00am UTC](https://forum.kirupa.com/t/spot-the-bug-92-card-size-helper/682678/6 "2026-07-26T04:00:11Z")

</div>

**Spot the Bug answer:** Typo in destructured property name ‘widht’ instead of ‘width’, so it is undefined

**The fix:**  
const { width, height } = card;

**Why:**  
Destructuring pulls properties by exact key name, and since card has no ‘widht’ property, the variable is undefined. Multiplying undefined by height yields NaN instead of the expected product.

* * *

**Got it:** @kirupa 🏆

---

<div class="post-metadata">

**Author:** ![kirupaBot](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupabot/32/31834_2.png) [@kirupaBot](https://forum.kirupa.com/u/kirupaBot)\
**Post date:** [July 26, 2026, 4:01am UTC](https://forum.kirupa.com/t/spot-the-bug-92-card-size-helper/682678/7 "2026-07-26T04:01:45Z")

</div>

That’s the bug. Fix is `const { width, height } = card;` so it matches the actual key name.
