diff options
Diffstat (limited to 'upd8-util.js')
-rw-r--r-- | upd8-util.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/upd8-util.js b/upd8-util.js index b94ffe3a..2fe2fcc8 100644 --- a/upd8-util.js +++ b/upd8-util.js @@ -57,3 +57,15 @@ module.exports.progressPromiseAll = function (msg, array) { return val; }))); }; + +module.exports.th = function (n) { + if (n % 10 === 1 && n !== 11) { + return n + 'st'; + } else if (n % 10 === 2 && n !== 12) { + return n + 'nd'; + } else if (n % 10 === 3 && n !== 13) { + return n + 'rd'; + } else { + return n + 'th'; + } +}; |