Spot the bug - #33

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 bug — JavaScript’s string method is toLowerCase() (capital C), so the current code hits undefined and then blows up when you try to call it.

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