
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Reversing All Alphabetic Characters in JavaScript
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
Advertisements