forked from Automedon/CodeWars-7-kyu-Soluitions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Alphabet symmetry
21 lines (14 loc) · 858 Bytes
/
Alphabet symmetry
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
Description:
Consider the word "abode". We can see that the letter a is in position 1 and b is in position 2. In the alphabet, a and b are also in positions 1 and 2. Notice also that d and e in abode occupy the positions they would occupy in the alphabet, which are positions 4 and 5.
Given an array of words, return an array of the number of letters that occupy their positions in the alphabet for each word. For example, solve(["abode","ABc","xyzD"]) = [4,3,1]. See test cases for more examples.
Input will consist of alphabet characters, both uppercase and lowercase. No spaces.
Good luck!
If you like this Kata, please try:
Last digit symmetry
Alternate capitalization
*/
function solve(arr){
var alphabeth = "abcdefghijklmnopqrstuvwxyz";
return arr.map(x => x.toLowerCase().split('').filter((y,i) => i==alphabeth.indexOf(y)).length);
};