Javascript missing letters

Tell us what’s happening:
Describe your issue in detail here.
In this code, what is the undefined return for ?, the code would not be complete with the return String.fromCharCode (code-1) ?, the return undefined is necessary

  **Your code so far**

function fearNotLetter(str) {
for (var i = 0; i < str.length; i++) {
  /* code of current character */
  var code = str.charCodeAt(i);
  /* if code of current character is not equal to first character + no of iteration
      hence character has been escaped */
  if (code !== str.charCodeAt(0) + i) {
    /* if current character has escaped one character find previous char and return */
    return String.fromCharCode(code - 1);
return undefined;

// test here
  **Your browser information:**

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

Challenge: Missing letters

Link to the challenge:

The undefined is for when no missing letters are present.

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