I see a lot of solutions removing characters without checking to see if they're "letters." Here's my JavaScript solution.
// Remove the first and last _letters_ in a stringfunctionremoveFirstLastLetters(str){if(str.length<3){returnnull;}else{constregex=/[a-zA-Z]/;letfirstCharIndex=str.search(regex);if(firstCharIndex===-1){returnnull;}else{letlastCharIndex=str.length-str.split("").reverse().join("").search(regex);returnstr.slice(0,firstCharIndex)+str.slice(firstCharIndex+1,lastCharIndex-1)+str.slice(lastCharIndex,str.length);}}}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I see a lot of solutions removing characters without checking to see if they're "letters." Here's my JavaScript solution.