Spot the bug - #54

This text cleanup has one bug.

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

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

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

1 Like

toLowercase() is the broken part — the String method is toLowerCase() (capital “C”), so this will throw a TypeError because you’re calling something that doesn’t exist. Fix:

function normalizeTag(tag) {
  return tag.trim().toLowerCase();
}
1 Like