# Help With "Missing Letters" Challenge Please \*SOLVED\*

**URL:** <https://forum.freecodecamp.org/t/help-with-missing-letters-challenge-please-solved/509608>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [May 19, 2022, 3:03am UTC](https://forum.freecodecamp.org/t/help-with-missing-letters-challenge-please-solved/509608 "2022-05-19T03:03:38Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![sol-dev-1](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sol-dev-1/32/260977_2.png) [@sol-dev-1](https://forum.freecodecamp.org/u/sol-dev-1)\
**Post date:** [May 19, 2022, 3:03am UTC](https://forum.freecodecamp.org/t/help-with-missing-letters-challenge-please-solved/509608/1 "2022-05-19T03:03:38Z")

</div>

Here’s my code so far:

```auto
function fearNotLetter(str) {
  let refStr = "abcdefghijklmnopqrstuvwxyz"; // Reference of the alphabet
  if (str === refStr) { // Checking that str isn't a full range
    return undefined;
  } else {
    let index = refStr.indexOf(str.charAt(0)); // Where to start cutting the reference
    let reducedRef = refStr.slice(index, str.length + 1); // str but complete
    return reducedRef.split("").filter(x => !str.includes(x)).join(); 
    // ^^^ Where I believe the issue is, but can't spot ^^^ :(
  }
}

/* 
Why is only one test failing, and why is it failing? (fearNotLetter("stvwx") specifically)
*/

```

It only fails the test “fearNotLetter(“stvwx”)”, but I have no idea why.

 ![image](https://global.discourse-cdn.com/freecodecamp/original/4X/0/c/2/0c216a37fc9a9a34a9d3a2528b6a371c15ed3e1e.png)

^^^ Here’s a picture of the failed test ^^^

Thanks in advance!

\*Edit

I found the bug in my code, I solved it by specifying the index at which to stop cutting the reference. Thanks for all the help guys!

Updated Code:

```function
  let refStr = "abcdefghijklmnopqrstuvwxyz"; // Reference of the alphabet
  if (str === refStr) { // Checking that str isn't a full range
    return undefined;
  } else {
    let beginIndex = refStr.indexOf(str.charAt(0)); // Where to start cutting the reference
    let endIndex = refStr.indexOf(str.charAt(str.length - 1)); // Where to stop cutting the reference
    let reducedRef = refStr.slice(beginIndex, endIndex); // str but complete
    return reducedRef.split("").filter(x => !str.includes(x)).join(); 
  }
}

```

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [May 19, 2022, 3:05am UTC](https://forum.freecodecamp.org/t/help-with-missing-letters-challenge-please-solved/509608/2 "2022-05-19T03:05:28Z")

</div>

What is the output when you run that test case? I think that is a very helpful hint if you run that test case manually.

---

<div class="post-metadata">

**Author:** ![sol-dev-1](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sol-dev-1/32/260977_2.png) [@sol-dev-1](https://forum.freecodecamp.org/u/sol-dev-1)\
**Post date:** [May 19, 2022, 8:27pm UTC](https://forum.freecodecamp.org/t/help-with-missing-letters-challenge-please-solved/509608/3 "2022-05-19T20:27:37Z")

</div>

Hey Jeremy, sorry for the late reply, but the failed challenge returns an empty string, “”.

![image](https://global.discourse-cdn.com/freecodecamp/original/4X/7/c/2/7c27fc2a8b622ba6f0d0edd150e922759aed7600.png)  
^^^ Here’s the result (on [CodePen.io](http://CodePen.io)) ^^^

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [May 19, 2022, 8:28pm UTC](https://forum.freecodecamp.org/t/help-with-missing-letters-challenge-please-solved/509608/4 "2022-05-19T20:28:53Z")

</div>

and what should it return?

---

<div class="post-metadata">

**Author:** ![sol-dev-1](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sol-dev-1/32/260977_2.png) [@sol-dev-1](https://forum.freecodecamp.org/u/sol-dev-1)\
**Post date:** [May 19, 2022, 11:26pm UTC](https://forum.freecodecamp.org/t/help-with-missing-letters-challenge-please-solved/509608/5 "2022-05-19T23:26:18Z")

</div>

I just realized I typed the test wrong on CodePen 🤦‍♂️.

![image](https://global.discourse-cdn.com/freecodecamp/original/4X/7/3/b/73b1eec0290450bea8e22ad64fc9b31178a48ac5.png)  
^^^Here’s the test I meant to do, it should return the string “u” because that’s the missing letter in the range.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [May 20, 2022, 8:59am UTC](https://forum.freecodecamp.org/t/help-with-missing-letters-challenge-please-solved/509608/6 "2022-05-20T08:59:30Z")

</div>

and the other one what should return?  
because that too gives the wrong output

---

<div class="post-metadata">

**Author:** ![sol-dev-1](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sol-dev-1/32/260977_2.png) [@sol-dev-1](https://forum.freecodecamp.org/u/sol-dev-1)\
**Post date:** [May 21, 2022, 2:38am UTC](https://forum.freecodecamp.org/t/help-with-missing-letters-challenge-please-solved/509608/7 "2022-05-21T02:38:54Z")

</div>

I doubt that the other one (fearNotLetter(“stuvwx”)) is even part of the challenge, as the only “full range” provided in the tests is the entire alphabet. Therefore, I don’t believe the code needs to account for “stuvwx” as an input.

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [May 21, 2022, 2:56am UTC](https://forum.freecodecamp.org/t/help-with-missing-letters-challenge-please-solved/509608/8 "2022-05-21T02:56:58Z")

</div>

Technically, “stuvw” is a perfectly valid input that should return `undefined`.

You are getting an empty string. So your filter has to be returning an empty array. So why is your filter returning an empty array?

---

<div class="post-metadata">

**Author:** ![sol-dev-1](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sol-dev-1/32/260977_2.png) [@sol-dev-1](https://forum.freecodecamp.org/u/sol-dev-1)\
**Post date:** [May 22, 2022, 3:19am UTC](https://forum.freecodecamp.org/t/help-with-missing-letters-challenge-please-solved/509608/9 "2022-05-22T03:19:23Z")

</div>

Thanks for the help, I’ve soled the issue.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [November 20, 2022, 3:19pm UTC](https://forum.freecodecamp.org/t/help-with-missing-letters-challenge-please-solved/509608/10 "2022-11-20T15:19:51Z")

</div>

Closed on November 20, 2022, 3:19pm UTC

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