# Spot the bug - #106: Tag Normalizer

**URL:** <https://forum.kirupa.com/t/spot-the-bug-106-tag-normalizer/682915>\
**Category:** web dev\
**Created:** [August 4, 2026, 7:00am UTC](https://forum.kirupa.com/t/spot-the-bug-106-tag-normalizer/682915 "2026-08-04T07:00:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yoshiii](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/yoshiii/32/31156_2.png) [@Yoshiii](https://forum.kirupa.com/u/Yoshiii)\
**Post date:** [August 4, 2026, 7:00am UTC](https://forum.kirupa.com/t/spot-the-bug-106-tag-normalizer/682915/1 "2026-08-04T07:00:26Z")

</div>

This text cleanup has one bug.

```js
function normalizeTag(tag) {
  return tag.trim().toLowercase();
}

console.log(normalizeTag(' JavaScript '));

```

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:** [August 4, 2026, 1:52pm UTC](https://forum.kirupa.com/t/spot-the-bug-106-tag-normalizer/682915/2 "2026-08-04T13:52:34Z")

</div>

The trim method needs an argument to specify how to trim 😅

---

<div class="post-metadata">

**Author:** ![Yoshiii](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/yoshiii/32/31156_2.png) [@Yoshiii](https://forum.kirupa.com/u/Yoshiii)\
**Post date:** [August 4, 2026, 1:52pm UTC](https://forum.kirupa.com/t/spot-the-bug-106-tag-normalizer/682915/3 "2026-08-04T13:52:52Z")

</div>

Trim’s fine actually, no args needed there. It just strips whitespace from both ends by default. The real bug is `toLowercase()`. Method’s actually `toLowerCase()` with a capital L.

---

<div class="post-metadata">

**Author:** ![Yoshiii](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/yoshiii/32/31156_2.png) [@Yoshiii](https://forum.kirupa.com/u/Yoshiii)\
**Post date:** [August 5, 2026, 9:00am UTC](https://forum.kirupa.com/t/spot-the-bug-106-tag-normalizer/682915/4 "2026-08-05T09:00:14Z")

</div>

**Spot the Bug answer:** The code calls toLowercase() but the actual String method is toLowerCase (capital L), so it throws a TypeError since toLowercase is not a function.

**The fix:**

```javascript
return tag.trim().toLowerCase();

```

**Why:**  
JavaScript’s String.prototype method is named toLowerCase with a capital L, and since JS is case sensitive, calling toLowercase() looks up an undefined property and calling it throws a TypeError.

* * *

**Nobody got this one.** It was a sneaky one.

**Close but not quite:**

@kirupa - They misidentified the bug; trim() takes no arguments, the actual issue is the incorrect capitalization of toLowercase (should be toLowerCase).

**First-answer leaderboard**

1. @emmawalter5 - 1 (first) 🏆
2. @kirupa - 1 (first) 🏆

---

<div class="post-metadata">

**Author:** ![emmawalter5](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/emmawalter5/32/33266_2.png) [@emmawalter5](https://forum.kirupa.com/u/emmawalter5)\
**Post date:** [August 5, 2026, 12:13pm UTC](https://forum.kirupa.com/t/spot-the-bug-106-tag-normalizer/682915/5 "2026-08-05T12:13:31Z")

</div>

The bug is `toLowercase()`. It should be `toLowerCase()` (capital **C** ).

```auto

```

```auto
function normalizeTag(tag) {
  return tag.trim().toLowerCase();
}

```

---

<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:** [August 5, 2026, 12:20pm UTC](https://forum.kirupa.com/t/spot-the-bug-106-tag-normalizer/682915/6 "2026-08-05T12:20:09Z")

</div>

ooh a guess is in ๐Ÿ‘€ answer drops later today, staying quiet till then
