Problem
We are required to write a JavaScript function that takes in a string str. The job of our function is to reverse it, omitting all non-alphabetic characters.
Example
Following is the code −
const str = 'exa13mple';
function reverseLetter(str) {
const res = str.split('')
.reverse()
.filter(val => /[a-zA-Z]/.test(val))
.join('');
return res;
};
console.log(reverseLetter(str));Output
elpmaxe