Missing letters - Need Explain Why This Answer Won't Pass Tests

Tell us what’s happening:

Hi, guys. I have already solved the problem using the CharCodeAt and fromCharCode methods. What I’d like to know is why this approach won’t work. All the tests have been passed except the last one even though it’s returning undefined.

Your code so far

function fearNotLetter(str) {
return str
.replace("abce", "d")
.replace("abcdefghjklmno", "i")
.replace("stvwx", "u")
.replace("abcdefghijklmnopqrstuvwxyz", undefined)


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36.

Challenge: Missing letters

Link to the challenge:

is this really how you want to pass the test?
looking at the input in the tests and giving the output like that?
and what about any other possible input?

1 Like

Anyway, replace always returns a string, so when you want to return the value undefined you are actually returning the string "undefined"

1 Like

I see. So it will always the string no matter. i just had a weird hypothesis and wanted to try it out, but I guess it won’t work out anyway.