DEV Community

Kurapati Mahesh
Kurapati Mahesh

Posted on

Javascript: Different ways to convert numbers into alphabets

Expectation: 1 -> a, 2 -> b, 3 -> c etc.

(5 + 9).toString(36); -> e
Enter fullscreen mode Exit fullscreen mode
String.fromCharCode(5 + 'A'.charCodeAt()); -> e
Enter fullscreen mode Exit fullscreen mode

In both, replace 5 with other number from 1 - 25. You will get corresponding alphabet.

Always, welcome any new approaches.

You can follow me here: https://twitter.com/urstrulyvishwak

Thanks.

Top comments (0)