Hey so I’ve managed to complete this by using a fix. I imagine this works just fine and isn’t a cheat, because if you want to find a missing Unicode letter, you would always know the upper and lower Unicode number limit and would set it to that.
But is there anyway of doing this differently?
function fearNotLetter(str) {
var arr = str.split('')
var newArr = arr.map(item => item.charCodeAt(arr))
for (var i = 0; i < newArr.length; i++) {
if (newArr[newArr.length - 1] >= 122) {
return undefined
}
else if (newArr[i] + 1 !== newArr[i + 1]) {
return String.fromCharCode(newArr[i] + 1)
}
}
}
If I don’t include the first ‘if’ part, when the entire lowercase alphabet is passed, it returns ‘}’ which is the unicode character for 123, or z + 1. How can I get it to just stop, when it realises that all numbers in the converted array are +1 of the one before it, why does it go a bit further and return something out of the array?
Thanks