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() 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".
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();
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():
function normalizeTag(tag) {
return tag.trim().toLowerCase();
}
:: Copyright KIRUPA 2024 //--