javascript charCodeAt digits code example
Example 1: how to convert char to number in js
// the first parameter is the index of the string to convert to an ascii code
"A".charCodeAt(0);
//output: 65
Example 2: javascript letters as number
const toChars = n => `${n >= 26 ? toChars(Math.floor(n / 26) - 1) : ''}${'ABCDEFGHIJKLMNOPQRSTUVWXYZ'[n % 26]}`;
// Examples
toChars(0); // A
toChars(1); // B
toChars(25); // Z