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.
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.
toLowercase() is the broken bit — JavaScript’s string method is toLowerCase() with a capital C, so your function will throw TypeError: tag. trim(. . . ). toLowercase is not a function. Fix:
function normalizeTag(tag) {
return tag.trim().toLowerCase();
}
:: Copyright KIRUPA 2024 //--