My code works on visual studio code but not on freecodecamp

hi,
when i test my code, it’s work but the freecodecamp app say “should return a string”. i don’t understand what is wrong.


function fearNotLetter(str) {
 let monIndex = 'abcdefghijklmnopqrstuvwxyz'
 let monIndexArray = [...monIndex];
 let arrayStr = [...str];
 let index = monIndexArray.indexOf(arrayStr[0]);
 let newArr = monIndex.slice(index, index+arrayStr.length)
 let arrVrai = [...newArr];
 let count = 0;
 arrVrai.map(function (element){
   if (arrayStr.indexOf(element) < 0){
     count = 1;
     return element;
   } 
 })
if (count == 0){
  return undefined;
}
}

fearNotLetter("abcdefghjklmno");
   **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0

Challenge: Missing letters

Link to the challenge:

Hi @nyko.wagner !

Welcome to the forum!

If you add a console.log(fearNotLetter("stvwx")) you should see that it returns undefined each time instead of the missing letter.

Thanks for your response.
If i put a console.log(element) instead of return element in my code i show the missing letter. So i don’t understand why in my if condition the return element doesn’t work.

The issue is that you are using map to try to return the missing letter.
But I don’t see any reason why you would need to use map at all.
Remember that map returns a new array based on the results from the call back function.

When I switch it to use a simple loop then the test passes.

Hope that helps!

thanks for your help.