Convert number to alphabet letter

Tags: , ,



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?

Answer

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

var value = 10;

document.write((value + 9).toString(36).toUpperCase());


Source: stackoverflow