Missing letters

function fearNotLetter(str) {

  let letters = /^[A-Za-z]+$/;
  let i = "a"; 

  for (i = 0; i < str.length; i += 1) {
    if (str.length === letters) {
      return undefined; 
    } else
    return //missing letter;



I am stuck, can someone help me out without giving me the answer?

Please always include a link to the challenge.

This doesn’t make sense. You are trying to compare a number (the length of str) to a regular expression. That is always going to be false.

Instead of trying to code this solution first, I would recommend you write out in plain English how you would go about solving this.

Sorry about that. Here’s the link for anyone that needed it

function fearNotLetter(str) {
// Step 1: Indicate the alphabet range
// Step 2: If all letters in str are present then return undefined 
// Step 3: If a letter in the str is not present then return the missing letter
// *Key: str must be in the correct order of the alphabet 


I wrote out in plain english how I would solve this, I think the difficult part is writing code that takes the order of the letters in the str into consideration, which I wrote as the key to this problem

Not in enough detail in my opinion:

This is just restating what the function is supposed to do. Now how exactly would you go about doing that?

Appreciate the honest feedback.

function fearNotLetter(str) {
// Step 1: Create a variable for the alphabet 
// Step 2: Create a for loop that checks if all the letters in the str are in the same order as they are in the alphabet 
// Step 3: If they are, return undefined 
// Step 4: If not, return the missing letter


I tried giving more detail in these steps. Other than these steps I wrote, I am unsure of any other way to approach this problem

Hey Zuko,
I went thru your description and code and basically you are right, you need to loop thru, you need to tell how to know the position in the alphabet and then compare. I dont think you can do that with a regex expression though. I mean, you would have to populate your own array where each letter of the alphabet represents an index and then compare with the length of the given argument.

But, why to invent the wheel a second time? Imagine that your pc has to tell which key was pushed, ofcourse this wouldnt be the same as we see, it would be hex to binary. So each letter/ character has already its very own number.

there is a function for getting that number


CharCodeAt JS docs

So as a next step I would suggest that you make your own function for getting those chars and then decide what to do next with that info.

Forgot one thing:
In the case of this conditional statement “str.length === letters” try to loop thru yourself.:

1. loop:  4 === /^[A-Za-z]+$/ ?
2. loop:  4 === /^[A-Za-z]+$/ ?
3. loop:  4 === /^[A-Za-z]+$/ ?
4. loop:  4 === /^[A-Za-z]+$/ ?

Does not make much sense anymore right?

function fearNotLetter(str) {
const stringabc = "abcdefghijklmnopqrstuvwxyz"; 

  for (let i = 0; i < stringabc.length; i += 1) {
    if (str.charCodeAt() - stringabc.charCodeAt(str.charCodeAt()) != 0) {
      return //missing letter; 
    return undefined;



I feel like I am close but I don’t know what I am doing wrong. I thought my code uses a for loop to look through stringabc then uses an if statement that says if the value of the letters in the str aren’t equal to the value of the same letters in their position of the alphabet…then return the missing letter, otherwise return undefined

Hiii, can someone please help me with this problem if they have the time? Thanks:)

Nevermind I got it :slight_smile: