Q: A bullet list of letter after letter 'z' I have this code to generate a bullet list with the alphabet:
angular.module('testApp',[])
.controller('testController', function($scope){
        var i = 0;
    $scope.options = [];
    for ( var j=0;j<100;j++ ){
        var x = "option "+j;
        $scope.options.push(x)
    }

})
.filter('numberToAlphabet', function(){
    return function(number){
        return String.fromCharCode(number+97);
    }
})

It generates a list like:
a. option 1
b. option 2
c. option 3
...

But the problem is that when after letter z of the alphabet, it shows me other characters. I would like, if it is posible, that it shows me after the letter z a list like:
aa. option 
ab. option
ac. option
ad. option

That is posible ?
any help ?

A: This is actually a fairly simple calculation, but kinda fiddly to get exactly right. Something like this:


function numberToAlpha(number) {
  var r = number % 26;
  var d = Math.floor(number / 26);
  if (d == 0) {
    return String.fromCharCode(r + 97);
  }
  return numberToAlpha(d - 1) + String.fromCharCode(r + 97);
}

// some tests...
for(var i = 0; i < 256; i++) {
  console.log(i + "\t" + numberToAlpha(i))
}


I used something similar to figure out the corresponding excel column given a numerical index because they use the same lettering scheme.
This will give you:
0    ->   a
1    ->   b
25   ->   z
26   ->   aa
27   ->   ab
28   ->   ac
52   ->   ba
99   ->   cv
1299 ->   awz

And you can adapt as needed (it wasn't clear if you want to be 0-indexed or 1-indexed)
