Published
- 1 min read
javascript letters as number
The solution for this is noted below
javascript letters as number
Solution
const toChars = (n) =>
`${n >= 26 ? toChars(Math.floor(n / 26) - 1) : ''}${'ABCDEFGHIJKLMNOPQRSTUVWXYZ'[n % 26]}`
// Examples
toChars(0) // A
toChars(1) // B
toChars(25) // Z
Try other methods by searching on the site. That is if this doesn’t work