this implementation is really ugly and very redundant.. maybe better to do something like:

```js
function ordinal(num){
    num = ~~num;
    if (num >= 10 && num <= 20) {
        return num + 'th';
    }
    var lastDigit = String(num).slice(-1);
    switch (lastDigit) {
        case '1':
            return num +'st';
        case '2':
            return num +'nd';
        case '3':
            return num +'rd';
        default:
            return num +'th';
    }
}
```

or:

```js
function nth(i) {
    var t = (i % 100);

    if (t >= 10 && t <= 20) {
        return 'th';
    } else {
        switch(i % 10) {
            case 1:
                return 'st';
            case 2:
                return 'nd';
            case 3:
                return 'rd';
            default:
                return 'th';
        }
    }
}

function ordinal(num){
   num = ~~num;
   return num + nth(num);
}
```