Angular js/javscript matcj (ordinal) suffix to a item total count

I have provided my code below on ordinal. What i want to know is that
how would I match every ordinal to my total items. For example If I have 3 items then tha would be. The number with ordinal will match to the total items. Another exam would be if i have 4 items which is . Thank you. please conside the {$ question $} from template as item.

    items = [a, b, c ,c ]
    letgh = 4

then it would be

    1st = a
    2nd = b
    3rd =c
    4th = d


#on template



 <ol class="playlist" kendo-sortable k-on-end="endHandler(kendoEvent)" k-placeholder="placeholder" k-hint="hint" ng-hide="questionArray.length == 0" >
                                <li type="" ng-repeat="question in questionArray" >
                          <h1 ng-repeat="x in r">{$ x $}</h1> {$ question $}           {$ question $} 
                              </span>-->
                                </li>
                            </ol>

#code




function nth(n) {
            return ["st", "nd", "rd"][((n + 90) % 100 - 10) % 10 - 1] || "th"
        }
        for ($scope.r = [], i = 1; i < $scope.questionArray.length + 1; i++) $scope.r.push(i + nth(i));
        console.log("olol:", $scope.r)

Source: AngularJS