I have a slight problem with this challenge. When I test it in my IDE I get perfectly fine results, but fcc doesn’t accept it all. Maybe you can have a look if I miss something or I just have a total wrong approach.
Like the others, I’d expect your solution to not work either, as your approach makes some assumptions that aren’t always going to be the case.
I just attempted that challenge myself and the way I did it was basically by taking advantage of ASCII codes, as it’s generally easier to work with numbers than characters. Of course you can use RegEx too, as mentioned, but that’s generally sort of a quick-fix approach and probably not the approach that FCC wants you to take since RegExs don’t involve “algorithmic scripting”.
This is my solution, there are plenty of others that would work too:
function fearNotLetter(str) {
let arr = str.split("");
let ascii = arr.map(x => x.charCodeAt(0));
for (let i = 1; i < ascii.length; i++) {
if (ascii[i] > ascii[i-1] + 1) {
return String.fromCharCode(ascii[i] - 1);
}
}
}