Intermediate: Missing Letters

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 = => 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?


I imagine that if the entire lower case alphabet is passed than you don’t have a missing letter. So when i is for the last character in the array, newArr[i + 1] will be the same as newArr[newArr.length], with a value of undefined.
The issue is not the range of the Unicode characters, but that you try to use an index for an array item that doesn’t exist

You don’t need that statement (which is also totally unneeded inside the loop as it doesn’t have the loop variable inside), instead you can do a small change to avoid the issue above