Missing letters undefined

How do I return undefined?

  **Your code so far**

function fearNotLetter(string) {
for (var i = 0; i < string.length; i++) {
  if (string.charCodeAt(i + 1) - string.charCodeAt(i) !== 1) {
    return String.fromCharCode(string.charCodeAt(i) + 1);
  }
}
return undefined;
}
let ans =fearNotLetter("abcdefghijklmnopqrstuvwxyz");

console.log(ans)
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36

Challenge: Missing letters

Link to the challenge:

What should happen when you get to the end of the alphabet?

'y'.charCodeAt()
// 121

String.fromCharCode(121 + 1)
// 'z'

'z'.charCodeAt()
// 122

String.fromCharCode(122 + 1)
// '{'

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.