Hi everyone, I think there’s a bug in the Missing Letter challenge ( Intermediate challenge ).
The first and Second solution seem to miss wrong, if I search more than one word in range, I only get the first letter missing.
and here’s the solutions I looked at. https://github.com/freeCodeCamp/freeCodeCamp/wiki/Algorithm-Missing-Letters
In fact, if I try to put ‘az’ the output is wrong,however I still manage to pass the challenge
Here’s my own code, also if you wish, you can tell me whether or not it’s decent enough. It checks every missing letter
On my own code I also used arrows, but I decided to put here a longer version for the sake of semplicity.
function fearNotLetter(str) {
str = str.split("");
var numbersInString = str.map(function(val) { // here we get the values of our starting point
return val.charCodeAt();
})
var numbersToCompare = []
for (x = numbersInString[0]; x < numbersInString[numbersInString.length -1] +1; x++) { // here we get and push all the values that go from starting to ending point
numbersToCompare.push(x)
}
var missingNumber = numbersToCompare.filter(function(val){ // here we get only the numbers(letters) we are missing
return numbersInString.indexOf(val) === -1;
});
var convertedMissingNumber = missingNumber.map(function(val){ // here we convert it to letters
return String.fromCharCode(val)
});
if (numbersToCompare.length === numbersInString.length) { // here we check whether or we have all the letters in the range
return undefined // <- if we do
}
return convertedMissingNumber.join("") // if we don't
}
fearNotLetter("ax"));
I don’t know if the challenge is meant to only look for the first missing character, also sorry if this has already been posted and I’m totally wrong !
I also wanted to thank freeCodeCamp, because it’s what got me into programming!