Last active
May 30, 2016 13:50
-
-
Save alexanderjeurissen/877d479143218c135113 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generateAlphaNumericLabels(amount) { | |
var labels = []; | |
for (var i = 0; i <= amount; i++) { | |
var appendNumber = 0; | |
var offset = 0; | |
if (i > 25 && i <= 34) { | |
appendNumber = i - 25; | |
labels.push(String.fromCharCode(65 + offset) + appendNumber); | |
} else if (i > 33) { | |
offset = Math.floor((i - 26) / 10); | |
appendNumber = i - (25 + (offset * 10)); | |
labels.push(String.fromCharCode(65 + offset) + appendNumber); | |
} else { | |
labels.push(String.fromCharCode(65 + i)); | |
} | |
} | |
return labels; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you wish to change it to the headers on excel documents for example, like continuous headers ["A",..."Z","A1",..."Z1","A2" ...] is really simple the change