xpedobearx xpedobearx - 2 years ago 240
Javascript Question

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?

Answer Source

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

var value = 10;

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download