1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
const p = console.log; const map = { ' ': 0, 'm': 1, ',': 2, '.': 3, 'j': 4, 'k': 5, 'l': 6, 'u': 7, 'i': 8, 'o': 9, }; const c2n = c => { return map[c]; }; const c2nLine = str => { let s = ''; for (const c of str) { s += c2n(c); } return s; }; p(c2nLine(' m,.jkluio')); // 0123456789 p(c2nLine('oiulkj.,m ')); // 9876543210 p(c2nLine(' .., ,,,,')); // 0332002222 |
1 2 3 |
0123456789 9876543210 0332002222 |