# Missing letters next step?

Hey I think I understand the `charCodeAt` and `fromCharCode` concepts but I’m not sure how I can check for differences in each index of str in order of index in alphabet.

My code is not complete and I understand it’s currently just checking if `str[i]` has `a` please let me know what to look at doing next.

Thanks

``````  **Your code so far**
``````
``````
function fearNotLetter(str) {
// initialize full alphabet
let alphabet = "abcdefghijklmnopqrstuvwxyz";
// get ASCII code using charCode
let code = alphabet.charCodeAt(); // 97
// convert ASCII back to string
let convertedStr = String.fromCharCode(code); // a
// check for differences in ASCII code between str and alphabet
for (let i = 0; i < str.length; i++) {
if (!str[i].includes(convertedStr)) {
return
}
}
// if there is a missing letter return the missing letter, else return undefined

return str;
}

console.log(fearNotLetter("abce"));

``````
``````  **Your browser information:**
``````

User Agent is: `Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36`.

Challenge: Missing letters

From looking at your current logic, it does not appear you have figured out a working algorithm for the problem. Let’s get your algorithm correct first before trying to write code.

If I were to give you the letters `a, b, c, e`, explain the steps you would take to figure out the missing letter. Don’t think about code, just explain your thought process of how you figure it out.

2 Likes

Yeah unfortunately I couldn’t get to that point. I did try thinking that way and commenting it out first but ended up here.

I would go through the sequence of str and check it with the alphabet (a,b,c then see it’s missing d). If it’s missing a letter in sequence I’d know which one.

I thought maybe use loop to go through but not sure how to do the part where I’m comparing to each index off alphabet based on which part it contains and check it with one another.

I know it’s best to write it out without code, check mozilla docs, and look at the hint. Sucks nobody can tell but I really do follow these steps. Maybe I just don’t do it well I guess… But I don’t know how to do it better than I have. I’m only posting a question when I can’t seem to make more progress

But how will you know it is missing “d”? What is the logic process to determine that? Once you figure that out, then you will have a working algorithm that you can code.

1 Like

I’ll compare it with the sequence in that portion of the alphabet. I initialized this as

It might help to console.log the charCodes for a string like `"abce"` or `"stvwx"`.

Describe the steps to accomplish this comparision. Forget programming something to do it. How do you manually figure it out yourself?

1 Like

@RandellDawson

2. I will know that abcde is the order needed
3. I will realize that it’s missing d because I know it needs to be abcde

Hope this helps I’m sorry I don’t understand how else to explain it

@jsdisco I actually did this and commented the result which seems to be the first index if there is to argument inside charCodes but I don’t know how to get it to where I need for this challenge.

This is the part you need to explain step by step in much more detail. This will be your algorithm for which you will write code. A computer does not know how to “recognize” something. You must give it a process to follow. Basically, you need to explain how you go from step 2 to step 3 as you described above. How will you use what you read in step 1 and capture the `abcde` in step 2? Then how will you use this information to conclude `d` was the missing letter.

When I say explain step by step, I mean literally walk us through how you would look at each letter in the string and tell us what actual comparisons to the step 2 string to be able to conclude `d` is the missing letter. Until you can detail each iteration of what comparisions are needed, it will be difficult to write code for what needs to happen.

1 Like

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