Skip to content
Advertisement

Convert number to alphabet letter

I want to convert a number to its corresponding alphabet letter. For example:

1 = A
2 = B
3 = C

Can this be done in javascript without manually creating the array? In php there is a range() function that creates the array automatically. Anything similar in javascript?

Advertisement

Answer

Yes, with Number#toString(36) and an adjustment.

var value = 10;

document.write((value + 9).toString(36).toUpperCase());
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement