Solution Feedback on Missing letters

Tell us what’s happening:
So I struggled a lot with this one but eventually found my way to a solution. After I checked the solutions given I feel like mine was terrible. Anyway I was hoping to get some feedback on just how bad it is I guess.
Your code so far

function fearNotLetter(str) {
  const arr = [];
  const originalArr = str.split('');
  
  for (let letter = 0; letter < str.length - 1; letter++){
    const ascii  = (str.charCodeAt(letter) + 1);
  
    arr.push((String.fromCharCode(ascii)));


  }
  return (arr.filter(element => !originalArr.includes(element)).join('') || undefined);
  
}


fearNotLetter("abcdefghijklmnopqrstuvwxyz");

Your browser information:

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

Challenge: Intermediate Algorithm Scripting - Missing letters

Link to the challenge:

These solutions are not intended to be used as a reference how it should be done. They are rather showing how it can be done. Often going for the sleekness or shortness instead of readability.

If it is working then it’s good enough for a first encounter with task like that. At the same time having working solution is good point to take another look and see what can be simplified or changed to make it clearer.

Do you have any specific parts that you think should be changed, or are especially hard to follow?

1 Like
const originalArr = str.split('');

Since strings already have an includes method, you do not need to create this extra array and can reference str in the return statement instead of originalArr,