Intermediate Algorithm Scripting - Missing letters

Hello everyone, i have two questions

To make it clear more, check the code blow, for more clarity, you will find the whole code below (this is the whole code) statement.

My questions are:

1- why did they added The iteration
B after str.charCodeAt(0)

if (charCode !== Str.charCodeAt(0) + B)

2- why did they subtracted 1?

return String.fromCharCode(charCode - 1);
if (charCode !== Str.charCodeAt(0) + B) {
  return String.fromCharCode(charCode - 1);

This is the whole code:

function fearNotLetter(Str) {
for (let B = 0; B < Str.length; B = B + 1) {
  const charCode = Str.charCodeAt(B);
if (charCode !== Str.charCodeAt(0) + B) {
  return String.fromCharCode(charCode - 1);
}
}
return undefined;
}

fearNotLetter("abce");


Your browser information:

User Agent is: Mozilla/5.0 (iPhone; CPU iPhone OS 17_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1.1 Mobile/15E148 Safari/604.1

Challenge Information:

Intermediate Algorithm Scripting - Missing letters

  • to get next character in sequence
  • to get missing character

did you try looking at it those values in console? if not then give it a try, also try to demystify what is happening in those “conditionals”

happy coding :slight_smile:

1 Like

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