Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ordinal suffix #493

Open
jwerre opened this issue May 18, 2016 · 0 comments
Open

Add ordinal suffix #493

jwerre opened this issue May 18, 2016 · 0 comments

Comments

@jwerre
Copy link

jwerre commented May 18, 2016

module.exports = function ordinal(num) {
    var suffix=["th","st","nd","rd"],
        val=num%100;
    return num+(suffix[(val-20)%10]||suffix[val]||suffix[0]);
};

_.ordinal(1) // 1st
_.ordinal(2) // 2nd
_.ordinal(3) // 3rd
_.ordinal(4) // 4th
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant