Posted on

number to characters function

This is a short snippet for converting number to characters in alphabet. For example, 3 should be D, 7 is H. It should be a problem when trying to convert a number bigger than 25 (length of alphabet is 26, I am counting from 0). It that case, we got more than one character – for example 26 is AA, 150 is FU, 2222 is DHM.

This code should be used for example for converting number of column to its name in Excel.

Code in coffeescript:


In javascript:


In action:

See the Pen coffeescript function for converting number to string of characters by Eidam (@eidam61) on CodePen.