 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP 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 the alphabet from back to front and front to back in JavaScript
We are required to write a JavaScript function that takes in a single alphabet as the only input. The function should compute the position of the that alphabet from starting and return an alphabet that’s at the same position but from the back.
Example
The code for this will be −
const alpha = 'g'; const findCounterPart = (alpha = '') => {    let alphabet = 'abcdefghijklmnopqrstuvwxyz';    let firstpart = alphabet.substring(0,13).split('');    let secondpart = alphabet.substring(13).split('').reverse();    let solution = '';    if (firstpart.indexOf(alpha) !== −1) {       solution = secondpart[firstpart.indexOf(alpha)];    } else {       solution = firstpart[secondpart.indexOf(alpha)];    };    return solution; }; console.log(findCounterPart(alpha));  Output
And the output in the console will be −
t
Advertisements
 