Tell us what’s happening: i didnt understand whats means { return String.fromCharCode(charCode - 1); } *
Describe your issue in detail here.
thanks
**
function fearNotLetter(str) {
for (let i = 0; i < str.length; i++) {
/ code of current character */
const charCode = str.charCodeAt(i);
/* if code of current character is not equal to first character + no of iteration
then a letter was skipped */
if (charCode !== str.charCodeAt(0) + i) {
/* if current character skipped past a character find previous character and return */
return String.fromCharCode(charCode - 1);
}
}
return undefined;
}
// test here
fearNotLetter(“abce”);**
function fearNotLetter(str) {
for (let i=0; i<str.length; i++) {
const charCode = str.charCodeAt(i);
if(charCode !== str.charCodeAt(0)+ i) {
return String.fromCharCode(charCode - 1);
})
}
return undefined;
}
fearNotLetter("abce");
//d
//abce
//0<4 97 = 97 97 !== 101 97+3 =100 97+4 101
//1 98
//2 99
//3 101
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edg/107.0.1418.56
Challenge: Intermediate Algorithm Scripting - Missing letters
Link to the challenge: