# Spot the bug - #47

**URL:** <https://forum.kirupa.com/t/spot-the-bug-47/681942>\
**Category:** web dev\
**Created:** [June 6, 2026, 7:00am UTC](https://forum.kirupa.com/t/spot-the-bug-47/681942 "2026-06-06T07:00:09Z")\
**Posts on this page:** 4\
**Page:** 1

<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:** [June 6, 2026, 7:00am UTC](https://forum.kirupa.com/t/spot-the-bug-47/681942/1 "2026-06-06T07:00:09Z")

</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:** ![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:** [June 7, 2026, 8:00am UTC](https://forum.kirupa.com/t/spot-the-bug-47/681942/2 "2026-06-07T08:00:14Z")

</div>

`toLowercase()` isn’t a JS string method (it’s `toLowerCase()` with a capital C), so it’ll throw `TypeError: tag. trim(. . . ). toLowercase is not a function`. Fix: `return tag. trim(). toLowerCase(); ` which will log `"javascript"`.

---

<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:** [June 7, 2026, 8:00am UTC](https://forum.kirupa.com/t/spot-the-bug-47/681942/3 "2026-06-07T08:00:22Z")

</div>

lol this is like missing a jump by 1 pixel — `toLowercase()` isn’t a real String method, so it’ll throw a `TypeError`.

Fix is just the capital C: `return tag.trim().toLowerCase();`

---

<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:** [June 7, 2026, 8:01am UTC](https://forum.kirupa.com/t/spot-the-bug-47/681942/4 "2026-06-07T08:01:56Z")

</div>

Yep — `toLowercase()` isn’t a thing on JS strings, so you’ll get `TypeError: tag.trim(...).toLowercase is not a function`. Change it to `toLowerCase()`:

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

```
