I just completely my Missing Letters but I just can’t get the last case. Can you see a bug?
function fearNotLetter(str) {
let alpha = 'abcdefghijklmnopqrstuvwxyz';
let range = alpha.slice(alpha.indexOf(str[0]), str.length + 1)
.split('')
.filter(value => !str.includes(value));
return range[0];
}
I understand I didn’t do the indented solution of comparing the ASCII code but this example works for all but ‘stvwx’ for some reason.
Thank You.
Challenge Link
sanity
2
Try to temporarily split it more into steps and see if at each step everything looks like it should.
I broke up your code into smaller pieces to let you see what is happening.
function fearNotLetter(str) {
let alpha = 'abcdefghijklmnopqrstuvwxyz';
console.log('alpha.indexOf(str[0]) = ' + alpha.indexOf(str[0]));
console.log('str.length + 1 = ' + (str.length + 1));
let slice = alpha.slice(alpha.indexOf(str[0]), str.length + 1);
console.log('slice = ' + slice);
let rangeArr = slice.split('');
console.log(rangeArr);
let range = rangeArr.filter(value => !str.includes(value));
console.log('range = ' + range);
return range[0];
}
console.log(fearNotLetter("stvwx")) // undefined
2 Likes
system
Closed
4
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.