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 broken — JavaScript strings have toLowerCase() (capital C). As written you’ll get TypeError: tag. trim(. . . ). toLowercase is not a function. Fix:
function normalizeTag(tag) {
return tag.trim().toLowerCase();
}
JS is case-sensitive, so that one character means the method isn’t found at runtime.
:: Copyright KIRUPA 2024 //--