Last active
December 27, 2015 13:59
-
-
Save NaWer/7337583 to your computer and use it in GitHub Desktop.
Convert letters to digits using "old" phone keybord
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _in = 'erwan123'; | |
var _out = []; | |
var map = ['0 ','1','2abc','3def','4ghi','5jkl','6mno','7pqrs','8tuv','9wxyz']; | |
for(var i = 0; i < _in.length; i++) | |
{ | |
for (var j = 0; j < map.length; j++) | |
{ | |
if (map[j] && map[j].indexOf(_in[i]) > -1) | |
{ | |
_out.push(j); | |
break; | |
} | |
} | |
} | |
console.log(_out.join('')); // output 37926123 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment