Hi! I’m trying to complete the _Intermediate Algorithm Scripting: Missing letters. This is the code i wrote.
I thought that negating the condition inside .filter() would have done the magic, but it returns me an empty array.
Am i completely wrong in my approach, so i can’t use filter this time, or am i close to the solution? Any hint?
function fearNotLetter(str) {
const alphabet = 'abcdefghijklmnopqrstuvwxyz'.split('');
const userStr = str.split('').sort();
//Find first and last chars of argument string
const strStart = userStr[0];
const strEnd = userStr[userStr.length-1];
//Split alphabet array to match argument string chars
const alphabetStart = alphabet.indexOf(strStart);
const alphabetEnd = alphabet.indexOf(strEnd);
const alphabetChunck = alphabet.slice(alphabetStart, alphabetEnd+1);
return str = userStr.filter( item => !alphabetChunck.includes(item) );
}
const test1 = fearNotLetter("abce");
console.log(test);