Tell us what’s happening:
So the challenge requires a missing letter of an alphabetic sequence to be returned. I’ve tested my solution with all the test input strings, and just before I return the result, I log it to the console, which always shows the correct letter. The line near the end where I enclose it in typical string brackets ("") doesn’t change the console result, nor the returned result, as displayed by all the challenges failing. I know it doesn’t return undefined, and the Get A Hint tab suggests using charCodeAt() somewhere, which I could do, but as of now I am more curious as to why the challenges fail, which according to the console, they do not.
Thank you in advance for any help!
Marcus.
Your code so far
function fearNotLetter(str) {
let newStr = str;
newStr = newStr.split("");
console.log(newStr);
let alpbet = "abcdefghijklmnopqrstuvwxyz";
alpbet = alpbet.split("");
console.log(alpbet);
let indexStart = alpbet.indexOf(newStr[0]);
let indexEnd = alpbet.indexOf(newStr[newStr.length-1]);
console.log(indexStart);
console.log(indexEnd);
let comparator = alpbet.slice(indexStart,indexEnd+1);
console.log(comparator);
let result = comparator.filter( letter => {
if (newStr.indexOf(letter)!=-1) {
return false;
} else {
return true;
}
})
console.log(result);
result = `"${result}"`; //Challenges still fail if omitted
console.log(result);
return result;
}
fearNotLetter("abcdefghjklmno");
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/missing-letters