There is a table like the table of Pythagoras.
If you know the number / letter from the column (left) and the number from the line (above), then how do you know the number / letter standing at the intersection in the table?

There is a table like the table of Pythagoras.
If you know the number / letter from the column (left) and the number from the line (above), then how do you know the number / letter standing at the intersection in the table?

Without using a matrix because of the pattern in the arrangement of letters in the table:
function getLetter(left, up) { var number = fromHex(up) * 16 + fromHex(left); var letterCode = 32; if (number >= 2 && number <= 27) { letterCode = number + 63; } else if (number >= 28 && number <= 37) { letterCode = number + 20; } else if (number >= 38 && number <= 63) { letterCode = number + 59; } return String.fromCharCode(letterCode); } function fromHex(char) { return parseInt(char + "", 16); } var letter = getLetter('C', '2'); console.log(letter); // Первое значение — ось Y, второе — X, var out = getItem('b', '0') console.log(out) // "J" function getItem(y, x) { // Тут переводим шестнадцатиричное число // в десятиричное, если требуется var args = arguments for(var i = 0; i < args.length; i++) { if(typeof args[i] === 'string') { args[i] = parseInt(args[i], 16) } } // Возвращаем ячейку по координатам return [ //0, 1, 2, 3 [ , 'O', '4', 'k'], // 0 [ , 'P', '5', 'l'], // 1 ['A', 'Q', '6', 'm'], // 2 ['B', 'R', '7', 'n'], // 3 ['C', 'S', '8', 'o'], // 4 ['D', 'T', '9', 'p'], // 5 ['E', 'U', 'a', 'q'], // 6 ['F', 'V', 'b', 'r'], // 7 ['G', 'W', 'c', 's'], // 8 ['H', 'X', 'd', 't'], // 9 ['I', 'Y', 'e', 'u'], // a ['J', 'Z', 'f', 'v'], // b ['K', '0', 'g', 'w'], // c ['L', '1', 'h', 'x'], // d ['M', '2', 'i', 'y'], // e ['N', '3', 'j', 'z'], // f ][y][x] } You can tailor it to your decision, where there will be numbers and capital, small letters. I hope that helped
var alphabet = "abcdefghijklmnopqrstuvwxyz".split(""); _.each(alphabet, function(letter) { console.log(letter); }); Source: https://ru.stackoverflow.com/questions/620667/
All Articles