Tell us what’s happening:
Hi, I found my own solution to the challenge using slice() and a filter() at the end. Now, when I console.log the results, all the tests are fine…but when I switch to return the solution, I don’t pass a single test.
If I change the string manually for testing purposes, my solution works fine.
Can someone spot what’s wrong?
Your code so far
function fearNotLetter(str) {
const alphabet = [...'abcdefghijklmnopqrstuvwxyz']
let start = alphabet.indexOf(str[0])
let finish = alphabet.indexOf(str[str.length-1])
let arr1 = alphabet.slice(start, finish+1)
if (arr1 === str) {
return undefined;
}
return arr1.filter(x=> str.indexOf(x) === -1)
}
fearNotLetter("abce");
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.79 Safari/537.36
.
Challenge: Missing letters
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/missing-letters